I need to to know
example of the dataset:
data = {'Proudct':['SLL', 'MNO', 'Drin', 'JAJ'],
'Product-ID':[20, 20, 19, 18]
'barcode':['3633', '7676', '2313','3311'}
df = pd.DataFrame(data) ```
I need the output to be like:
Name ID Code
SLL 20 3633
MNO 20 7676
Use groupby
+ transform('count')
:
filtered = df[df.groupby('Product-ID')['barcode'].transform('count') > 1]
Output:
>>> filtered
Proudct Product-ID barcode
0 SLL 20 3633
1 MNO 20 7676