Reputation: 43
I need to delete rows from a dataframe which have "No" value in column Auto-Investment. How to do that using pandas dataframe?
index = 0
for x in df3['Auto-Investment']:
if x == 'No':
rows = df3.index(index)
df3.drop(rows, inplace=True)
index += 1
print(df3)
Upvotes: 0
Views: 51
Reputation: 1658
Number of solutions:
1. df3 = df3[df3['Auto-Investment']!='No]
2. df3.drop(df3['Auto-Investment']!='No].index, inplace=True)
Discussion on which solution is better: Pandas drop rows vs filter
Upvotes: 1
Reputation: 1048
You can do it by deselecting the ones that are 'no'.
df3 = df3[df3['Auto-Investment']!='No']
Upvotes: 1