I'm trying to upload a pandas dataframe to a big query with all the nan values changed to NULL values. I've already tried using
df = df.where(pd.notnull(df), None)
But the output still shows NaN values.
CodePudding user response:
Is your column numeric? For numeric columns, None is converted to nan when a DataFrame or Series containing None is created, or None is assigned to an element.
Please see Working with missing data from the documentation.
CodePudding user response:
As the great mozway, answered in his comment.
You can fill any np.nan or any simbology that means 0 values by utilizing of the df.fillna()
method. In your case df.fillna('NULL')
, although is worth noting. That using such conversion, isnt exactly recommended. Since everytime you may want to substitue your null values, you may require some not needed extra steps when you try to make any analysis on top of it.