I have this code
import pandas as pd
import numpy as np
import csv
df = pd.DataFrame({'animal': 'cat dog cat fish dog cat cat'.split(),
'size': list('SSMMMLL'),
'weight': [8, 10, 11, 1, 20, 12, 12],
'adult' : [False] * 5 + [True] * 2});
And I changed the weight with NA values:
df['weight'] = np.nan
And finally I saved it
df.to_csv("ejemplo.csv", sep=";", decimal=",", quoting=csv.QUOTE_NONNUMERIC, index=False)
But when I read the file I have "", instead of NA I want to put NA instead of Nan
I want as output:
adult;animal;size;weight
False;"dog";"S";NA
False;"cat";"M";NA
na_repsodf.to_csv("ejemplo.csv", sep=";", decimal=",", quoting=csv.QUOTE_NONNUMERIC, index=False, na_rep='NA')- EdChum