Reputation: 13
How can I remove all the rows if the value of one column list is empty?
so the end result looks like this:
Upvotes: 0
Views: 57
Reputation: 862396
If there are empty lists, cast them to boolean, we will get True
s for non-empty values and filter them using boolean indexing
:
df = df[df['ids'].astype(bool)]
But if empty strings ()
compare for not equal:
df = df[df['ids'].ne('()')]
Upvotes: 1
Reputation: 3608
You can use list comprehension:
df["id"] = [x for x in df["id"] if len(x) >= 1]
Upvotes: 0