Tsallaka zuwa abun ciki
Justice Tech School

Unique and Duplicates

drop_duplicates removes repeated rows and duplicated marks them.

Example
df = pd.DataFrame({"a": [1, 1, 2], "b": ["x", "x", "y"]})
print(df.duplicated().tolist())
print(df.drop_duplicates())
print(df["a"].nunique())

Result

[False, True, False]
   a  b
0  1  x
2  2  y
2

Exercise

Remove repeats.

df.()

Quiz Test

What does nunique count?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.