Reputation: 67
Ive tried a lot of combination how to remove this empty list from a dataframe, but it didnt work.
index_names = self.df[self.df['stopwords'].len()==0].index
self.df.drop(index_names, inplace=True)
dataframe called df['stopwords'] and it looks like this
goal is to delete the entire row of a dataframe with [] list
Upvotes: 1
Views: 290
Reputation: 323226
Try astype
with bool
, since []
will return False
df = df[df['stopwords'].astype(bool)]
Upvotes: 2
Reputation: 24304
IIUC:
try if they are actual list object:
self.df.loc[~df['stopwords'].map(lambda x:not x)]
else if they are strings then use:
self.df.loc[df['stopwords'].ne('[]')]
Upvotes: 2