So some values in one of the columns in my dataframe are ''. When I save the df as a CSV using .to_csv() to use it in another function I get a csv with null values.
So some values in one of the columns in my dataframe are ''. When I save the df as a CSV using .to_csv() to use it in another function I get a csv with null values.
Use replace:
df.replace('', 'null').to_csv(file)
#if need specify only some column
df.replace({'A': {'': 'null'}}).to_csv(file)
If empty values are NaNs add parameter na_rep for convert all NaNs to another value:
df.to_csv(file, na_rep='null')