-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Make DataFrame.to_string output full content by default #28052
Merged
WillAyd
merged 28 commits into
pandas-dev:master
from
lshepard:issue9784-to-string-truncate-long-strings
Sep 16, 2019
Merged
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
af444f0
Added a parameter to pass all the way down to specify max_colwidth. N…
00a43cc
I have threaded the max_colwidth parameter all over the place, but I'm
1ebf091
Ok, I removed all the deep changes and parameter-passing. Instead, we…
21bbf64
For some reason, the truncation switches justification if the max_col…
cfde48e
Added a test to show that this option exists for to_string
1abc2fa
Shortened one line (split across two). It's hard to actually shorten …
a1d3832
Shortened all the lines even in the test to comply with PEP8
3cf9a6a
Adding a newline per suggestion from isort
762d677
Solved the justify problem, and also added some None value for the ma…
d64fcb8
Swap out format to be None, ignore justification issues.
6e792f8
Reformat blac.
6a5cd97
Merge branch 'master' into issue9784-to-string-truncate-long-strings
889284f
Merge branch 'master' into issue9784-to-string-truncate-long-strings
3116ea1
Use the is_nonnegative_int validator for the max_colwidth param. I di…
840c1a6
Added entry to whatsnew.
2c68bbc
Fixed formatting with black.
4e7fe82
Split whatsnew entry, add versionadded, reorder params
90f0ee0
Remove double line break
c2b8421
Oops, didn't mean to update this script
5a8a525
Merge branch 'master' into issue9784-to-string-truncate-long-strings
da031f2
Correct word in whatsnew.
20d10b5
Merge branch 'master' into issue9784-to-string-truncate-long-strings
0f8119e
Update doc/source/whatsnew/v1.0.0.rst
732c2f4
Resolve conflict in whatsnew
affef02
Merge suggested edits
3efa1da
Merge branch 'master' into issue9784-to-string-truncate-long-strings
6142150
Merge branch 'master' into issue9784-to-string-truncate-long-strings
b23da91
Resolve conflict correctly.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Wanted to note - one of the commenters on the issue asks: "With Pandas 0.25.0, setting display.max_colwidth to a large number stops the truncation but when trying to left justify columns with df.to_string(justify='left'), that same display setting somehow pads columns on the left so they are not left aligned. Is there any present way to prevent truncation and get left justified string columns when output to a terminal? I know a pull request is in process but I would like to do this now. Thanks."
I can accomplish this in my testing by setting
max_colwidth=0
, which switches the padding to left. It is weird, though, that passingjustify="left"
does not justify it correctly. Seems like maybe a separate bug or one that I could look further into.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.
I'm not sure I understand this cause, but I don't think we'll want a workaround like this.
Can you post the output with
max_colwidth=0
, and how it compares to this?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.
This shows how the max_colwidth=0 strangely forces a left justification:
Whereas the behavior in this PR preserves the right justification that is the current default:
And interestingly, passing
justify='left'
doesn't have an effect:This is because of these lines in _make_fixed_width:
It checks if
conf_max > 3
to apply the dot truncation ... so if it's <= 3 then that isn't called. So it's not just 0 but any of 0, 1, 2, or 3 that causes the justification to line up.I can spend some more time to better understand why this is happening. I agree that we should not rely on some incidentals of the underlying implementation to determine whether to justify the text.
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.
Ok, I figured out the issue. There are two lines where
format_array
is called and thejustify
parameter is not passed all the way through -- so in some places, the justification is being overridden.Note that the bug where justification doesn't happen if conf_max < 3 already appears - so I think it can probably be pulled out as a separate PR.
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.
Scratch all that. I re-read the docs and I see that I misinterpreted the
justify
param, as it only refers to the column headers, not the content. In that regard it is behaving correctly. So I think I'll leave the justification question out of this PR.