Skip to content
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: add between DateOffsets raises error #36590

Open
GYHHAHA opened this issue Sep 24, 2020 · 2 comments
Open

BUG: add between DateOffsets raises error #36590

GYHHAHA opened this issue Sep 24, 2020 · 2 comments
Labels
Enhancement Error Reporting Incorrect or improved errors from pandas Frequency DateOffsets Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@GYHHAHA
Copy link
Contributor

GYHHAHA commented Sep 24, 2020

>>> pd.offsets.Day(1) + pd.offsets.Day(1)
<2 * Days>
>>> pd.offsets.DateOffset(days=1) + pd.offsets.DateOffset(days=1)
TypeError                                 Traceback (most recent call last)
 in 
----> 1 pd.offsets.DateOffset(days=1) + pd.offsets.DateOffset(days=1)

pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.BaseOffset.__add__()

pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.apply_wraps.wrapper()

TypeError: Argument 'other' has incorrect type (expected datetime.datetime, got DateOffset)

I think they should give the same output.

>>>pd.offsets.DateOffset(days=1) - pd.offsets.DateOffset(days=1)
<0 * DateOffsets: days=1>

And the substraction works fine.

@GYHHAHA GYHHAHA added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 24, 2020
@GYHHAHA GYHHAHA changed the title BUG: add or sub between DateOffsets raises error BUG: add between DateOffsets raises error Sep 24, 2020
@jbrockmendel
Copy link
Member

Having subtraction work while addition doesnt is definitely not good. We can certainly make the exception here clearer.

In general, users should not expect DateOffset addition to work.

@mroeschke
Copy link
Member

xref #10902

@mroeschke mroeschke added Error Reporting Incorrect or improved errors from pandas Frequency DateOffsets and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 24, 2020
@jbrockmendel jbrockmendel added the Numeric Operations Arithmetic, Comparison, and Logical operations label Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Error Reporting Incorrect or improved errors from pandas Frequency DateOffsets Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

3 participants