Skip to content

interation of set_eng_float_format and pivot_tables #11981

Closed
@ChristopherShort

Description

@ChristopherShort

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateOutput-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions