Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Replace all empty lists ([], '[]') in dataframe with NaN's
- df = df.mask(df.applymap(str).eq('[]'))
- # Replace all zeros in dataframe with NaN's
- df[df == 0.0] = np.nan
- # Replace empty strings in dataframe with NaN's
- df.replace('', np.nan, inplace=True)
- # Replace all strings with value 'null' in a dataframe with NaN
- df.replace('null', np.NaN, inplace=True)
- mask = df.applymap(str).isin(["[]", 0.0, "", "null"])
- df = df.where(~mask, other=np.nan)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement