0

There is a number of questions about suppressing scientific notation in Pandas in general

However, none of them seems to apply to the to_markdown function. For example:

import pandas as pd

df = pd.DataFrame({'val': 3e10}, index=[0])  # print(df) gives 3.000000e+10
pd.set_option('float_format', '{:f}'.format) # print(df) gives 30000000000.000000

However, df.to_markdown() still yields

|    |   val |
|---:|------:|
|  0 | 3e+10 |

How can I disable the scientific notation in to_markdown()?

Dahn
  • 253
  • 1
  • 2
  • 13

1 Answers1

1

I figured out the answer during writing the question.

df.to_markdown() uses tabulate under the hood. We can thus use the floatfmt parameter mentioned in the tabulate readme to disable the formatting:

print(df.to_markdown(floatfmt=''))

yields

|    |           val |
|---:|--------------:|
|  0 | 30000000000.0 |
Dahn
  • 253
  • 1
  • 2
  • 13