I have a column in my dataframe that contains a list of names with such a structure:
df['name']=[
['anna','karen','',]
['', 'peter','mark','john']
]
I want to get rid of the empty strings i tried it with list comprehension
[[name for name in df['name'] if name.strip()] for df['name'] in df]
But that doesnt work at all, is there a way to do it? I also used the replace method from pandas by replacing the empty strings to nan but that also doesnt work as it always throws a key error...
df['name'].replace('', np.nan)