My DF looks like below
Date New_date X Y
01-12 01-12 3 4
01-13 01-13 6 1
01-14 01.15 2 3
I need this result:
Date New_date X Y
01-14 01.15 2 3
o code should remove first 2 rows because values in columns Date and New_date are the same. I tried with this:
df.drop(df.loc[df['Date'] == df['New_date']])
But it doesn't work. Any idea?
Best regards and thanks for help
Change logic - get all rows if not equal values.
So change ==
to !=
for not equal values and filter in boolean indexing
:
df = df[df['Date'] != df['New_date']]
print (df)
Date New_date X Y
2 01-14 01.15 2 3