1

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

dataframe looks like this

goal is to delete the entire row of a dataframe with [] list

2 Answers2

2

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('[]')]
Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
2

Try astype with bool, since [] will return False

df = df[df['stopwords'].astype(bool)]
BENY
  • 317,841
  • 20
  • 164
  • 234