Blair  - Soul Eater 183. Customers Who Never Order

• data analysis/PYTHON

183. Customers Who Never Order

oujin 2023. 12. 28. 17:09
728x90

customers 테이블: id, name

+----+-------+
| id | name  |
+----+-------+
| 1  | Joe   |
| 2  | Henry |
| 3  | Sam   |
| 4  | Max   |

orders 테이블: id, customerId

+----+------------+
| id | customerId |
+----+------------+
| 1  | 3          |
| 2  | 1          |
+----+------------+

 

Q. 구매하지 않은 고객의 이름을 출력하시오

Output: 
+-----------+
| Customers |
+-----------+
| Henry     |
| Max       |
+-----------+

 

A. ~ isin 을 사용하기

never_o = pd.DataFrame()

never_o['Customers'] = customers [~customers.id.isin( orders.customerId)]['name']

return never_o

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90