pandas remove nan string code example
Example 1: pandas replace empty string with nan
df = df.replace(r'^\s*$', np.NaN, regex=True)
Example 2: python remove nan rows
df = df[df['my_var'].notna()]
df = df.replace(r'^\s*$', np.NaN, regex=True)
df = df[df['my_var'].notna()]