简体   繁体   中英

How do i suppress exponential display output

I am having difficulty to format a simply float column in a dataframe:

output_df['ann_avg_prem'].map('${:,.2}'.format)

I would like output that resembles:

0 $1,650.00
1 $1,650.00

But for some reason, I cannot suppress the exponential notation. I would like to maintain space in my presentation output for up to $99,999,999.99.

Here is what I am getting instead:

0    $ 1.6e+03
1    $ 1.6e+03
2    $ 1.6e+03
3    $ 1.6e+03
4    $ 1.6e+03
Name
e: ann_avg_prem, dtype: object

I seriously cannot make any sense of the documentation for formatting, and everything I am trying is giving me an error message.

Add f specifier:

 df.x.map('${:,.2f}'.format)
 #               ^ this

Output:

0    $1,650.00
1    $1,650.00
Name: x, dtype: object

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