As numpy.nan is a special float type in python, I have a pandas.Dataframe, some columns are consists of integer and Nan. As we know these columns will be float datatype. I want to copy pandas.Dataframe.to_csv , a CSV file,to database. But as those columns in CSV are float datatype (even I set 'object' type for them in pandas but they are converted to float when I do .to_csv), but the table schema of those columns in DB are the integer type, so they will be rejected to load in. this is the problem I got. what would be a good way to fix this? It's not good to change the DB schema.
for example I have a data = pandas.Dataframe() as below. ID: float Value: float
ID Value
0 1001.0 500.0
1 1002.0 NaN
2 NaN 600.0
3 1003.0 800.0
How could I create a csv to be like this:
ID|Value
1001|500
1002|
|600
1003|800
'{:0.0f}'.format(0.)?