Skip to content

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.

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

2 participants