The data-frame, df:
ID status year
1 0 2000
1 1 2000
2 0 2001
3 1 2002
3 0 2002
4 1 2002
I want to drop '0' status when '1' status is available for the same ID under the same year, such that:
ID status year
1 1 2000
2 0 2001
3 1 2002
4 1 2002
I have used following code:
df.drop_duplicates(subset=['year', 'id'], keep="first")
But the above code drops out some nonzero rows.