interation of set_eng_float_format and pivot_tables · Issue #11981 · pandas-dev/pandas (original) (raw)

There appears to be an interaction between the option for float display length and pivot_table methods on integers. This issue arose when working on a dataset with both floats and integers - but this arose on operations on integers part of the dataset.

The following example throws an error from the format.py module.

Swap the comments on the formatting options (undoing the setting for floats) and it runs fine.

In my dataset - there were no missing values following the pivot table operation and the error still occurs. In the sample code below, NaNs may be causing the formatting issue, but that didn't appear to be the case for me.

import pandas as pd import numpy as np

#pd.set_option('display.float_format', None) pd.set_eng_float_format(accuracy=1)

df = pd.DataFrame(data = np.random.randint(25, size=(10, 3)), columns = list('abc')) df.pivot_table(values='a', index='b', columns='c')

cheers
Chris