I have a dataframe that resembles the following:
Name | Amount |
---|---|
A | 3,580,093,709.00 |
B | 5,656,745,317.00 |
Which I am then applying some styling using CSS, however when I do this the Amount values become scientific formatted so 3.58009e 09 and 5.39538e 07.
Name | Amount |
---|---|
A | 3.58009e 09 |
B | 5.65674e 07 |
How can I stop this from happening?
d = {'Name': ['A', 'B'], 'Amount': [3580093709.00, 5656745317.00]}
df = pd.DataFrame(data=d)
df= df.style
df
CodePudding user response:
You are not showing how you are styling the columns but, to set it as a float with two decimals, you should add the following to your styler, based on the first line of Pandas documentation (they write it for something):
df = df.style.format(formatter={('Amount'): "{:.2f}"})
Here is the link for more information: https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html