I have a Pandas dataframe with some empty rows which I'd like to drop. I found some similar questions (e.g., this one and this one), but none of the solutions worked for me.
Here is what I've tried:
# Solution 1: (replace whitespace with nan and dropna()
replies_texts['text'].replace('', np.nan, inplace=True)
replies_texts.dropna(subset=['text'], inplace=True)
# Solution 2:
replies_texts = replies_texts.replace(r'^\s*$', np.nan, regex=True)
# Solution 3:
replies_texts = replies_text.replace(r'^\s+$', np.nan, regex=True)
# Solution 4:
replies_texts = replies_text.apply(lambda x: x.str.strip()).replace('', np.nan)
#Solution 5:
replies_texts = replies_text.replace(r'\s+', np.nan, regex=True).replace('',np.nan)
Can someone please let me know why the above solutions don't work?