-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.to_string with formatters, header and index False #13350
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
BUG: DataFrame.to_string with formatters, header and index False #13350
Conversation
is this related to #13032 ? can you show an example of before / after |
@@ -9,6 +9,17 @@ | |||
_multiprocess_can_split_ = True | |||
|
|||
|
|||
def test_to_string_formatters_index_header(): | |||
from pandas import DataFrame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number (this PR since there is no number) as a comment
if you need the import put at the top of the file
Turns out is exactly related to #13032. I did see this issue, but didn't make the connection initially. In my testing, the lines should be removed not modified. To be honest, I didn't understand what these lines accomplished when I was reviewing the code originally. Minimal code to reproduce (stripped down from #13032, easier to see with
Before (adding slashes to make space counting easier): Output from PR for #13032 (without formatter):
Output from PR for #13032 (with formatter
I will add the PR and Issues numbers plus make corrections shortly. |
Current coverage is 84.23% (diff: 100%)@@ master #13350 diff @@
==========================================
Files 138 138
Lines 50713 50721 +8
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 42715 42723 +8
Misses 7998 7998
Partials 0 0
|
Additionally, the failed Travis CI checks don't appear to be related to my subtrations/additions. Lastly, the unit test must use |
@barrymoo can you also read thru the comments on that issue (and the referenced one) and see if covering bases. |
@jreback Of course, From comment #13032 (comment):
After (desired output, correct?):
I think the others comments would be unaffected. To be fair though, I am very new to pandas. |
I see what you mean now. From #11833: Code:
I should be able to fix this issue quickly. |
A different perspective: where are those spaces coming from in the first place? (I will try to track this down) |
Code:
Produces:
I believe this is the desired output. Unfortunately, this code fails about 20 tests. Hopefully, it is because the spacing in the expected output has changed slightly. |
About 30 failed checks from |
I have created barrymoo/pandas-pr-13350-supplement to document the test failures (and eventually generate new |
I have added some more tests to the supplement. There is one test which I am having some difficulty with, starts: https://github.com/barrymoo/pandas-pr-13350-supplement/blob/master/tests.py#L474. I think the frame is supposed to overcome the terminal size, but it doesn't. |
Hey @jreback I finished my supplement but I need some opinions about output formatting especially concerning the For the supplement, clone it, activate the dev environment (tested with 2 & 3, but have not examined diffs of the output), run |
@barrymoo not sure what you mean by supplement. simply update this PR, comments can just be done here. |
@barrymoo I live in Japan and am willing to check the output format amd provide test cases:) |
@jreback I ripped out the failing tests so one can easily print the results out on the command line. That way I can get some input from the community on how people want things formatted and make additional changes. |
Here's a great example for why I need the supplement. For
But, do you like:
or...
I can easily generate all of these outputs. Or, would you rather I pick what I like and get all of the tests working. |
I also worked on this; getting all of the tests to pass afterward is a nightmare. It looks like this change removes the leading space on integers but leaves it on floats. Is that true? |
@evanpw it's very time consuming. I am still working through all of the tests, but I don't have a ton of free time. If you're looking at all positive numbers there is an extra space for the nonexistent "-" sign. There is an example in one of the above comments. |
After this change there won't be an extra leading space for a column of positive integers, but there will still be one for a column of positive floats, right? |
That's correct, but I can likely fix that too. Again the majority of this work is fixing the tests. |
Author: sinhrks <[email protected]> Closes #13677 from sinhrks/append_series and squashes the following commits: 4bc7b54 [sinhrks] ENH: Series.append now has ignore_index kw
closes #13598 Author: wcwagner <[email protected]> Closes #13690 from wcwagner/bug/13598 and squashes the following commits: 9669f3f [wcwagner] BUG: "Replaced isinstance with is_integer, and changed test_pad_width to use getattr" 40a3188 [wcwagner] BUG: "Switched to single test method asserting functions that use pad raise correctly." 06795db [wcwagner] BUG: "Added tests for width parameter on center, ljust, rjust, zfill." 468df3a [wcwagner] BUG: Add type check for width parameter in str.pad method GH13598
closes #13603 Author: yui-knk <[email protected]> Closes #13687 from yui-knk/fix_13603 and squashes the following commits: 0960395 [yui-knk] BUG: Cast a key to NaT before get loc from Index
…st entry closes #13695 Author: Jeff Reback <[email protected]> Closes #13698 from jreback/merge_asof and squashes the following commits: c46dcfa [Jeff Reback] BUG: merge_asof not handling allow_exact_matches and tolerance on first entry
closes #12995 flake8-ed *.pyx files and fixed errors. Removed the E226 check because that inhibits pointers (e.g. char*). Author: gfyoung <[email protected]> Closes #14147 from gfyoung/pyx-flake8 and squashes the following commits: 386ed58 [gfyoung] MAINT: flake8 *.pyx files
* MAINT: Replace datetools import in tests * MAINT: Replace datetools import internally * DOC: Replace datetools import in docs * MAINT: Remove datetool imports from scripts * DEPR: Deprecate pandas.core.datetools Closes gh-14094.
Concatting categoricals with non-matching categories will now return object dtype instead of raising an error. * ENH: concat and append now can handleunordered categories * reomove union_categoricals kw from concat
* DOC: remove examples on Panel4D (caused warnings) and refer to older docs * DOC: fix build warnings * resolve comments
* DOC: clean-up 0.19.0 whatsnew file * further clean-up * Update highlights * consistent use of behaviour/behavior * s/favour/favor
closes #14088 Author: John Liekezer <[email protected]> Closes #14090 from conquistador1492/issue_14088 and squashes the following commits: c91425b [John Liekezer] BUG: fix tz-aware datetime convert to DatetimeIndex (GH 14088)
closes #14190 Author: Chris <[email protected]> Closes #14191 from chris-b1/cat-ctor and squashes the following commits: 4cad147 [Chris] add some nulls to tests da865e2 [Chris] BUG: Categorical constructor not idempotent with ext dtype
closes #14171 Author: Josh Howes <[email protected]> Closes #14182 from josh-howes/bugfix/14171-series-str-contains-only-nan-values and squashes the following commits: c7e9721 [Josh Howes] BUG: fix str.contains for series containing only nan values
can you rebase / update? |
…m/barrymoo/pandas into dataframe-to_string-minor-bug-fix
I didn't do this correct, sorry have not mastered this bit of git yet. I will submit a different pull request |
closes #13032
pep8radius master --diff
Found this bug experimenting with formatters. First pull request to pandas, but I believe guidelines are quite clear. I can explain what was happening in more detail if that is necessary.