In this question, my goal is to preserve the last trailing zeros
when exporting the DataFrame
to CSV
My dataset
looks like this:
EST_TIME Open High
2017-01-01 1.0482 1.1200
2017-01-02 1.0483 1.1230
2017-01-03 1.0485 1.0521
2017-01-04 1.0480 1.6483
2017-01-05 1.0480 1.7401
...., ...., ....
2017-12-31 1.0486 1.8480
I import and create a DataFrame and save to CSV by doing this:
df_file = '2017.csv'
df.to_csv(df_file, index=False)
files.download(df_file)
When I view the CSV, I see this:
EST_TIME Open High
2017-01-01 1.0482 1.12
2017-01-02 1.0483 1.123
2017-01-03 1.0485 1.0521
2017-01-04 1.048 1.6483
2017-01-05 1.048 1.7401
...., ...., ....
2017-12-31 1.0486 1.848
All the zeros at the end are gone. I want to preserve the trailing zeros when I save the CSV and I want it at 4 decimal place.
Could you please let me know how can I achieve this?