I am trying to apply a style.format
function to a data frame in order to adjust the number of decimal places, since the round()
function does not apply. (I don't understand why.)
The data in the df
are of the format 123.0
, 432.0
, and 543.0
, but I need them to have two decimal places (e.g., 123.00
).
I have verified with the function df.dtypes
that the column is of type float
.
I tried to apply the following:
import pandas.io.formats.style
import pandas as pd
df['DD'] = df[['Quantity']].style.format("{:.2%}")
df
But the following appears in the DD
field:
<pandas.io.formats.style.Styler object at 0x7f...
The round()
function does not work on the column either.
What can be done?