Closed danolson1 closed 3 years ago
@danolson1 I think the function you are looking for is pandas.DataFrame.round.
In your case you might want to use your_df.round(decimals=your_decimals)
. If this doesn't work, then convert to float first with .astype(float)
I don't want it to actually round the values. df.style.format({'column_name': '{:.2f}'})
is a workaround, but it would be more convenient if there was a global option to set this for all pint data types.
You can use pint's string formatting options by setting the ureg's default format:
pint_pandas.PintType.ureg.default_format = "~P"
https://pint.readthedocs.io/en/stable/tutorial.html#string-formatting
Thanks. That's just what I was looking for.
How do I control the number of decimal places that are displayed when Pint objects with float magnitudes are displayed in a Pandas DataFrame?