Is there a way to suppress scientific notation in Panda's outputs without forcing a particular precision across all columns?
So that a data frame:
import pandas as pd
df = pd.DataFrame({"a": [0.01, 0.02, 0.03], "b": [0.0000001, 0.0000002, 0.0000003]})
df.to_csv(
"df.csv",
index=False,
)
That initially would be outputted as:
a | b |
---|---|
0.01 | 1.00E-07 |
0.02 | 2.00E-07 |
0.03 | 3.00E-07 |
Instead becomes my desired output:
a | b |
---|---|
0.01 | 0.0000001 |
0.02 | 0.0000002 |
0.03 | 0.0000003 |
Many questions about suppressing scientific notation in Pandas' .to_csv results have already been asked, but all of the answers involve specifying an arbitrary precision.
For instance, setting float_format="%.7f"
in df.to_csv
forces 7 significant digits for all float columns and numbers (and so does round(7)
, of course).
This would lead to the following output, which I don't want:
a | b |
---|---|
0.0100000 | 0.0000001 |
0.0200000 | 0.0000002 |
0.0300000 | 0.0000003 |
(I also tried using np.format_float_positional
as suggested here, but had no luck.)