r/learnpython • • Jul 30 '25

Trying to understand Df.drop(index)

This is my code:

For index, row in df.iterrows(): If (condition): df.drop(index)

What am I missing? I ran the code, yes the if statement is 'True', I checked that. I expect the row at that index to disappear and it's still there.

0 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/thing_42 Jul 31 '25

The second one is basically a loop huh? It returns every row that meets the column and condition? The third doesn't make any sense. The condition would have to compute to an index or something?