简体   繁体   中英

How to suppress scientific notation in values in a pandas dataframe?

I have pandas.DataFrame that contains some values with scientific notation and I want to change those values to a normal value without the e+.. .

import pandas as pd
df = pd.DataFrame(
    [7.70000e+05, 4.5000000e+09, 3.219500e+05, 25000, 476577], 
    columns = ['Price'])

You can try something like this:

pd.set_option("float_format", lambda x: f"{x:.2f}")
df
          Price
0     770000.00
1 4500000000.00
2     321950.00
3      25000.00
4     476577.00

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM