Is there a way in pd.read_csv to replace NaN value with other character?
Putting this into the read_csv function does work:
dtype={"count": pandas.Int64Dtype()}
i.e.
df = pd.read_csv('file.csv')
This type supports both integers and pandas.NA values so you can import without the floats becoming integers.
If necessary, you can then use regular DataFrame commands to clean up the missing values, as described in other answers here.
BTW, my first attempt to solve this changes the integers into strings. If that's of interest:
df = pd.read_csv('file.csv', na_filter= False)
(It reads the file without replacing any missing values with NaN).
I have some data in csv file.
Because it is collected from machine,all lines should be number but some NaN values exists in some lines.And the machine can auto replace these NaN values with a string '-'.
My question is how to set params of pd.read_csv() to auto replace '-'values with zero from csv file?