Allow DataFrame.to_csv to represent inf and nan differently (original) (raw)
I would like the DataFrame.to_csv method to have an option to store inf values as "inf" and nan values as "nan". This will be important for computations that use inf and nan differently.
Currently:
In [72]: df = pd.DataFrame({'A': [inf]})
In [73]: print isinf(df)
A
0 True
In [74]: df.to_csv('temp.csv')
In [75]: df2 = pd.read_csv('temp.csv', index_col=0)
In [76]: print isinf(df2)
A
0 False
In the new implementation (possibly with an option passed to df.to_csv to select it), the result of isinf(df2) would be True.