-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Justification is broken with to_string(index=False) #13032
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
Comments
yeah looks like the prior fix only dealt with integers. a more comprehensive fix would be ok. |
The formatting issue seems more broad to me. This example demonstrates:
Produces this:
|
Might affect this.
|
Note that only the header line is shifted incorrectly. My current workaround is this (data is the DataFrame):
|
@hawkeyej certainly love for a PR to fix! just write up a test of the correct results, and use your fix; see what else breaks :) |
Initial work in #14196, can possibly be used as a basis (it needs tests) |
Ping. Annoying bug, can I help? Though I'm not a pandas expert... |
With index=False the column labels are not correctly aligned with the data, as leading spaces are stripped. Remove the index from the formatted table ourself. See pandas-dev/pandas#13032
With 0.17.1, justification is handled correctly:
But in 0.18.0, it's broken:
This is caused by PR #11942. The issue it was meant to fix (#11833) is actually caused by using the format string "% d" for formatting integers, which produces a leading space if the integer is positive (where the minus sign would go for a negative integer). My preferred solution would be to change the formatter to "%d" (and to revert #11942), which would have the added bonus of eliminating double spaces between some columns (see the first
to_string
output in #11833, for example). A bunch of formatting tests would have to be adjusted, though. Is there anyone who prefers the extra space?The text was updated successfully, but these errors were encountered: