Reputation: 79
Relatively new to Pandas so I apologize in advance if this is redundant. I have successfully sorted data in my CSV file, but I would like to delete all the rows for which I no longer need. For example here, I would like to keep rows where trade date and settle date are the same but delete rows for which they are different.
Trade Date Settle Date Security
8/15/2017 8/15/2017 a
9/7/2017 9/11/2017 b
8/31/2017 9/6/2017 c
I am guessing I need to add True False Booleans but the code I used to try that did not seem to work for me. Any help is appreciated.
booleans=[]
for length in df_new:
if 'Trade Date'=='Settle Date':
booleans.append(True)
else:
booleans.append(False)
Upvotes: 0
Views: 1352
Reputation: 403120
df = df[df['Trade Date'] == df['Settle Date']]
df
Trade Date Settle Date Security
0 8/15/2017 8/15/2017 a
Upvotes: 1