Answers for ".duplicated pandas"

3

python - show repeted values in a column

df = df[df.duplicated(subset=['val1','val2'], keep=False)]
Posted by: Guest on September-08-2020
0

pandas.duplicated

>>> df.duplicated(subset=['brand'])
0    False
1     True
2    False
3     True
4     True
dtype: bool
Posted by: Guest on June-23-2021
-1

pandas.duplicated

>>> df.duplicated(keep='last')
0     True
1    False
2    False
3    False
4    False
dtype: bool
Posted by: Guest on June-23-2021
-1

pandas.duplicated

>>> df = pd.DataFrame({
...     'brand': ['Yum Yum', 'Yum Yum', 'Indomie', 'Indomie', 'Indomie'],
...     'style': ['cup', 'cup', 'cup', 'pack', 'pack'],
...     'rating': [4, 4, 3.5, 15, 5]
... })
>>> df
    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
Posted by: Guest on June-23-2021

Python Answers by Framework

Browse Popular Code Answers by Language