Reputation: 23
I have a dataframe like:
'a' 'b' 'c' 'd'
0 1 2 3
3 3 4 5
9 8 8 8
and I want to remove rows that have a number that repeats more than once. So the answer is :
'a' 'b' 'c' 'd'
0 1 2 3
Thanks.
Upvotes: 2
Views: 48
Reputation: 863731
Use DataFrame.nunique
with compare length of columns ad filter by boolean indexing
:
df = df[df.nunique(axis=1) == len(df.columns)]
print (df)
'a' 'b' 'c' 'd'
0 0 1 2 3
Upvotes: 5