I have a dataset of orders and people who have placed those orders. Orders have a unique identifier, and buyers have a unique identifier across multiple orders. Here's an example of that dataset:
| Order_ID | Order_Date | Buyer_ID |
|----------|------------|----------|
| 123421 | 01/01/19 | a213422 |
| 123421 | 01/01/19 | a213422 |
| 123421 | 01/01/19 | a213422 |
| 346345 | 01/03/19 | a213422 |
| 567868 | 01/05/19 | a346556 |
| 567868 | 01/05/19 | a346556 |
| 234534 | 01/10/19 | a678909 |
I want to be able to filter the dataset to individuals who have only placed one order, even if that order has multiple items:
| Order_ID | Order_Date | Buyer_ID |
|----------|------------|----------|
| 567868 | 01/05/19 | a346556 |
| 567868 | 01/05/19 | a346556 |
| 234534 | 01/10/19 | a678909 |
If I try df[df['Buyer_ID'].map(df['Buyer_ID'].value_counts()) == 1] I get a really weird situation where the resulting dataframe is only rows where there's a 1 to 1 relationship between Order_ID and Buyer_ID. Like this:
| Order_ID | Order_Date | Buyer_ID |
|----------|------------|----------|
| 346345 | 01/03/19 | a213422 |
| 234534 | 01/10/19 | a678909 |
In the result I want, Buyer_ID a213422 should not appear at all because that person has more than one Order_ID.
This leads me to believe that value_counts() is either not the appropriate way to perform this filter, or I'm doing it wrong. What would be the appropriate way to perform this filter?