xxxxxxxxxx
import pandas as pd
# Create a sample DataFrame
data = {'Name': ['John', 'Bob', 'Alice', 'John', 'Bob'],
'Age': [25, 30, 28, 25, 30]}
df = pd.DataFrame(data)
# Find and display duplicate rows
duplicate_rows = df[df.duplicated()]
print(duplicate_rows)
xxxxxxxxxx
import pandas as pd
# Shows count of all the rows with duplicate values
df.duplicated(keep=False).sum()
xxxxxxxxxx
animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama'])
>>> animals.duplicated()
xxxxxxxxxx
In [28]:
df.groupby(df.columns.tolist(),as_index=False).size()
Out[28]:
one three two
False False True 1
True False False 2
True True 1
dtype: int64