Reputation: 173
I've just started using Pandas and I'm trying to export my dataset using the to_csv
function on my dataframe fp_df
One column (entitled fp_df['Amount Due']
)has multiple decimal places (the result is 0.000042) - but when using to_csv it's being output in a scientific notation, which the resulting system will be unable to read. It needs to be output as '0.000042'.
What is the easiest way to do this? The other answers I've found seem overly complex and I don't understand how or why they work.
(Apologies if any of my terminology is off, I'm still learning)
Upvotes: 1
Views: 5173
Reputation: 40747
Check the documentation for to_csv()
, you'll find an attribute called float_format
df.to_csv(..., float_format='%.6f')
you can define the format you want as defined in the Format Specification Mini-Language
Upvotes: 5