2021年5月3日星期一

How to check which customers are holding both products in Pandas

I have a dataframe as follows, with many customers and only 2 products (A and B). It is possible for a customer to hold multiple instances of the same product (e.g customer 1 has 4 product A's in the below table). How can I get a list of all customer who hold both products A and B (regardless of quantity)? Thanks.

e.g. the below table should only return customer ID of 1 and 2 since customer 3 only holds product B.

Customer ID Product
1 A
1 B
1 A
2 A
2 A
1 A
2 B
1 A
3 B
1 A
https://stackoverflow.com/questions/67378635/how-to-check-which-customers-are-holding-both-products-in-pandas May 04, 2021 at 12:01PM

没有评论:

发表评论