-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: repr aligning left for string dtype columns #54801
Conversation
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.
Yes, if the formatter converts to object dtype anyway, then this looks like a fine short term solution.
pandas/core/indexes/base.py
Outdated
if is_string_dtype(values.dtype): | ||
values = np.asarray(values) |
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.
if is_string_dtype(values.dtype): | |
values = np.asarray(values) | |
if is_string_dtype(values.dtype): | |
# ensure we have an object dtype numpy array | |
values = np.asarray(values) |
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Looking at the code in |
Yeah that's correct, we can set justify=all, but this screws with Index formatting if the index has a NaN because we are doing something weird. But that's too big for this here, that's why I went with the short term solution |
You can get this "bug" as well for other data types because of this left alignment. For example with numeric index:
(will move this to the issue) |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.cc @jorisvandenbossche this is a bit hacky, but changing format_array breaks index-related stuff. Don't feel comfortable to do this now, can be a follow up (we are casting to object anyway, so this does not impact performance)