python - How to change numeric data format for html output -
i have code produce pandas dataframe , send email in html format.
problem have hard change scientific format of numeric numbers general in style
i tried set float format, did not work.
pd.options.display.float_format = '{:20,.2f}'.format output:
col col b 1.00e+06 2.28e+06 3.00e+07 -2.54e+07 expected out:
col col b 1000420 2281190 30030200 -25383100
i tried , worked:
df = pd.dataframe([[3.371e17,9.82173e15],[8e12,8e8]],columns=['a','b']) df.to_html(float_format='{:20,.2f}'.format) this not changing formatting of df in general, html output, is:
<table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>a</th> <th>b</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>337,100,000,000,000,000.00</td> <td>9,821,730,000,000,000.00</td> </tr> <tr> <th>1</th> <td>8,000,000,000,000.00</td> <td>800,000,000.00</td> </tr> </tbody> </table>
Comments
Post a Comment