Skip to content

BUG: Fix behavior of to_offset with leading zeroes #6391

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

Merged
merged 3 commits into from
Feb 18, 2014

Conversation

ischwabacher
Copy link
Contributor

Currently, pandas.tseries.frequencies.to_offset erroneously returns a zero time offset when the first part of its argument has a numerical value of zero, even if later parts have nonzero values. For instance,

In [123]: pandas.tseries.frequencies.to_offset('00H 00T 01S')
Out[123]: <0 * Days>

This change checks the sign of the numeric part of the argument before converting to int in order to support offsets like '-00H 00T 01S'.

Currently, `pandas.tseries.frequencies.to_offset` erroneously returns a zero time offset when the first part of its argument has a numerical value of zero, even if later parts have nonzero values.  For instance,

    In [123]: pandas.tseries.frequencies.to_offset('00H 00T 01S')
    Out[123]: <0 * Days>

In this patch the sign check is applied before conversion to `int` in order to support offsets like `'-00H 00T 01S'`.
@jreback
Copy link
Contributor

jreback commented Feb 18, 2014

this is fine; can you add a release note (referencing this PR) in Bug Fixes section.

thanks

@jreback jreback added this to the 0.14.0 milestone Feb 18, 2014
@jreback
Copy link
Contributor

jreback commented Feb 18, 2014

edit source/doc/release.rst

@ischwabacher
Copy link
Contributor Author

Found it. Thanks!

@ischwabacher
Copy link
Contributor Author

I assume I don't have to merge your fix for the test failure into this branch; let me know if I do.

@@ -96,6 +96,7 @@ Improvements to existing features
Bug Fixes
~~~~~~~~~

- Bug in ``pd.tseries.frequencies.to_offset`` when argument has leading zeroes (:issue:`6391`)
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, we usually put the bug fixes at the end, but ok

@jreback
Copy link
Contributor

jreback commented Feb 18, 2014

@ischwabacher nope....you could pull master and then rebase (which would pick it up)....but not really necessary as their is no conflict here

thanks for the fix!

jreback added a commit that referenced this pull request Feb 18, 2014
BUG: Fix behavior of to_offset with leading zeroes
@jreback jreback merged commit b3a52f5 into pandas-dev:master Feb 18, 2014
@ischwabacher ischwabacher deleted the patch-1 branch February 20, 2014 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants