Skip to content

interation of set_eng_float_format and pivot_tables #11981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ChristopherShort opened this issue Jan 7, 2016 · 7 comments
Closed

interation of set_eng_float_format and pivot_tables #11981

ChristopherShort opened this issue Jan 7, 2016 · 7 comments
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@ChristopherShort
Copy link

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

@jreback
Copy link
Contributor

jreback commented Jan 7, 2016

not so friendly, needs a nan-check before handing off to Decimal.

want to do a pull-request?

@jreback jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Output-Formatting __repr__ of pandas objects, to_string labels Jan 7, 2016
@jreback jreback added this to the Next Major Release milestone Jan 7, 2016
@ChristopherShort
Copy link
Author

OK - I'll have a go since you've classified it as a novice level issue. Last time I tried (with a csv issue in 2014), I got lost very quickly. I'll get back to you in a week or so.

cheers

@jreback
Copy link
Contributor

jreback commented Jan 7, 2016

@ChristopherShort ok thanks. lmk.

@yaduart
Copy link
Contributor

yaduart commented May 9, 2016

Hi,
This is my first bug fix. If this bug has been schedule to released in the next major release, which document should I update in doc/source/whatsnew/vx.y.z.txt (would it be the document v0.18.2)

Regards,
Yadu

@jreback
Copy link
Contributor

jreback commented May 9, 2016

0.18.2

@ChristopherShort
Copy link
Author

yadu - thanks - this has been on my conscience for a couple of months (the 1 week blew right past).

I'll find something else I can contribute too.

@yaduart
Copy link
Contributor

yaduart commented May 10, 2016

No worries. cheers.

@jreback jreback modified the milestones: 0.18.2, Next Major Release May 10, 2016
yaduart added a commit to yaduart/pandas that referenced this issue May 10, 2016
Closes pandas-dev#11981

Updated the v0.18.2 document

Updated the document v0.18.2.txt and the test test_nan

Updated test_nan for smoke test
jreback pushed a commit that referenced this issue Sep 13, 2016
EngFormatter throws an exception if passed 'inf' as below.    This
patch checks for infinity and just returns 'inf' in that case.

xref #11981

Author: Johnny Gill <[email protected]>

Closes #14214 from swfiua/master and squashes the following commits:

f2348e7 [Johnny Gill] test EngFormatter with np.inf
83f4091 [Johnny Gill] add check for infinity in __call__ of EngFormatter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants