mini-kep / parser-rosstat-kep

Provide clean macroeconomic time series as CSV files at stable URL
12 stars 13 forks source link

shorter decimal representation in CSV file #157

Closed epogrebnyak closed 6 years ago

epogrebnyak commented 6 years ago

On output we have values like 9932.600000000002, while the actual value is 9932.6 (see https://github.com/mini-kep/parser-rosstat-kep/blob/dev/data/processed/2017/12/dfq.csv)

Can we ensure we write 9932.6 to csv files? Maybe shoud use decimal representation.

liepieshov commented 6 years ago

Actually the values are becoming longer in create_dataframe() and when taking diff() of df in deacc_main()

epogrebnyak commented 6 years ago

Great, but what should be done next? Anyhting in line of: https://stackoverflow.com/questions/19912611/pandas-script-modifying-numbers-to-long-float-numbers-when-it-shouldnt-even-be

Try changing your to_csv lines to include the argument float_format='%.4f' which will round things to 2 decimal places.