BUG: display.precision options seems off-by-one  (GH10451)
State: closed

Closes #10451 

I made a call here in response to my questions on #10451 and hopefully people like it. I made it clear that "precision" refers to places after the decimal, not significant figures, and changed the default value to match so that for many pandas users no change would be detected. I updated the Options docs and also What's New. For tests I basically updated the precision setting to the new semantics, so that the expected strings wouldn't need to change.

The one question I have is the code that computes `too_long`. This compares the longest formatted string against what looks to be an arbitrary constant of "number of digits + 5". Changing the 5 to a 4 or 6 doesn't trip up any unit tests. If it's desired, this could be increased by 1 as the "new" digits value is effectively 1 less than what the old value in terms of its effects on formatting, so the 5 would need to change to a 6 to maintain behavior. I could write tests on this as well.


Labels:
name: Bug
name: Output-Formatting
description: __repr__ of pandas objects, to_string

Comments:
Ok, I added a test for "too_long". I don't like testing display logic like this, it's very finicky... but it seemed that the right thing to do was to change the magic triggering constant, and to then have a test for it.

I do like the change overall.

@jreback Somehow the Travis indication isn't showing up for the build of a0190be but it did pass: https://travis-ci.org/rosnfeld/pandas/builds/70825379 (maybe the Github/Travis linkage got confused by a few quickly amended commits on my part?)

Is there anything else you would like to see here? 

@jreback Ok I've tried to address your comments, and Travis is happy with the result. 

Hi @jreback - just trying to learn the process for releases. I see a fair number of un-merged PR's for 0.17.0, including this one, I assume that's intentional? Is there anything else I need to do?

@rosnfeld this looked good - will take another look in a bit
generally: it's just a matter of me cycling thru the open ones
then I give feedback; it's iterative and if the authors are not responsive it can take longer
otherwise feel free to ping 

@jorisvandenbossche ?

@jreback thanks for the feedback (and info), I pulled the whatsnew comments to their own earlier sub-section, and elaborated the options.rst text a bit

@jreback ok I think I addressed your latest comments. BTW I have been seeing a strange Travis test failure that has been affecting my Travis builds but not the main pydata/pandas build:

```
FAIL: test_deprecated_labels (pandas.tests.test_categorical.TestCategorical)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/rosnfeld/pandas/pandas/tests/test_categorical.py", line 1193, in test_deprecated_labels
    self.assertFalse(LooseVersion(pd.__version__) >= '0.18')
AssertionError
```

Any ideas what is causing this?

@rosnfeld I recall seeing this somewhere but can't remember what the problem/fix was.

this on travis only?

@jreback yes, travis only, can't repro locally. And oddly not all builds... "2.7 slow and not network and not disabled" seems to pass, but none of the other mandatory builds do. Strange.

Looks good!

@rosnfeld thank you sir!