Skip to content

BUG: Align Series.str.zfill() with str.zfill() #21874

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

Closed
wants to merge 2 commits into from

Conversation

atulagrwl
Copy link

@atulagrwl atulagrwl commented Jul 12, 2018

Using standard library zfill method directly to handle specific characters issue

@gfyoung gfyoung changed the title BUG: Fixing Series.str.zfill() to behave same as str.zfill() from sta… BUG: Align Series.str.zfill() with str.zfill() Jul 12, 2018
@gfyoung gfyoung added Bug Strings String extension data type and string data labels Jul 12, 2018

if not is_integer(width):
msg = 'width must be of integer type, not {0}'
raise TypeError(msg.format(type(width).__name__))
Copy link
Member

@gfyoung gfyoung Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test for this validation.

@gfyoung
Copy link
Member

gfyoung commented Jul 12, 2018

@atulagrwl : Good start! Need a whatsnew entry in 0.24.0 as well.

@atulagrwl
Copy link
Author

Added the validation test in last commit and added whatsnew entry too.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add

  • whatsnew note, other api changes, need a sub-section showing the previous and the new behavior
  • check docs in text.rst to see if anything needs updating, if not pls add small example of usage there.

@@ -2220,27 +2220,31 @@ def test_center_ljust_rjust_fillchar(self):
result = values.str.rjust(5, fillchar=1)

def test_zfill(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue mentions also affecting rjust, pad, center, can you add / update tests as needed for those as well.

@@ -84,6 +84,7 @@ Other Enhancements
- :meth:`Series.nlargest`, :meth:`Series.nsmallest`, :meth:`DataFrame.nlargest`, and :meth:`DataFrame.nsmallest` now accept the value ``"all"`` for the ``keep`` argument. This keeps all ties for the nth largest/smallest value (:issue:`16818`)
- :class:`IntervalIndex` has gained the :meth:`~IntervalIndex.set_closed` method to change the existing ``closed`` value (:issue:`21670`)
- :func:`~DataFrame.to_csv` and :func:`~DataFrame.to_json` now support ``compression='infer'`` to infer compression based on filename (:issue:`15008`)
- :func:`Series.str.zfill()` now matches with standard string library zfill (:issue:`20868`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments, make this a sub section in api breaking (yes its a bug fix, but an unexpected one)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, parentheses not needed at the end of zfill in the :func: ref.

@jreback
Copy link
Contributor

jreback commented Sep 25, 2018

can you rebase

@jreback
Copy link
Contributor

jreback commented Nov 23, 2018

closing as stale. if you'd like to continue, pls ping.

@jreback jreback closed this Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.str.zfill() behaves differently than str.zfill() from standard library
4 participants