-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix string formatting #52883
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
Fix string formatting #52883
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.
Please always add tests.
Whatsnew should go into 2.0.1
…andas into fix_string_formatting
I have added the requested changes |
Co-authored-by: Matthew Roeschke <[email protected]>
|
||
Fixed regressions | ||
~~~~~~~~~~~~~~~~~ | ||
- Fixed regression when :meth:`DataFrame.to_string` creates extra space for string dtypes (:issue:`52690`) |
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.
Could you merge in main and add this to the existing v2.0.2.rst
file instead?
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, should have done this
GH #52690 | ||
|
||
""" | ||
# Expected Output |
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.
Could you remove these comments?
@@ -33,6 +34,7 @@ Other | |||
~~~~~ | |||
- Raised a better error message when calling :func:`Series.dt.to_pydatetime` with :class:`ArrowDtype` with ``pyarrow.date32`` or ``pyarrow.date64`` type (:issue:`52812`) | |||
|
|||
|
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.
Could you undo these new whitespaces?
Co-authored-by: Matthew Roeschke <[email protected]>
@@ -1392,7 +1392,10 @@ def _format(x): | |||
fmt_values = [] | |||
for i, v in enumerate(vals): | |||
if not is_float_type[i] and leading_space or self.formatter is not None: |
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 not is_float_type[i] and leading_space or self.formatter is not None: | |
if (not is_float_type[i] or self.formatter is not None) and leading_space: | |
fmt_values.append(f" {_format(v)}") |
if leading_space: | ||
fmt_values.append(f" {_format(v)}") | ||
else: | ||
fmt_values.append(f"{_format(v)}") |
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 leading_space: | |
fmt_values.append(f" {_format(v)}") | |
else: | |
fmt_values.append(f"{_format(v)}") |
It seems this if/else is already handled by the else block below. I think a smaller change is sufficient. WDYT? @reddyrg1 @mroeschke @phofl
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.