[1]:
import pandas as pd
[11]:
df = pd.DataFrame({
'brand': ['Yum Yum', 'Yum Yum', 'Indomie', 'Indomie', 'Indomie'],
'style': ['cup', 'cup', 'cup', 'pack', 'pack'],
'rating': [4, 4, 5.0, 15, 5]
})
[7]:
df
[7]:
| brand | style | rating | |
|---|---|---|---|
| 0 | Yum Yum | cup | 4.0 |
| 1 | Yum Yum | cup | 4.0 |
| 2 | Indomie | cup | 3.5 |
| 3 | Indomie | pack | 15.0 |
| 4 | Indomie | pack | 5.0 |
[8]:
df.duplicated()
[8]:
0 False
1 True
2 False
3 False
4 False
dtype: bool
[13]:
df.drop(columns='style').duplicated(keep=False)
[13]:
0 True
1 True
2 True
3 False
4 True
dtype: bool
[23]:
b=df.eq(df.iloc[0]).all(axis='columns')
b
[23]:
0 True
1 True
2 False
3 False
4 False
dtype: bool
[24]:
b[0]
[24]:
True
[ ]: