Skip to content

YearOffset issue #29827

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
cibic89 opened this issue Nov 24, 2019 · 1 comment
Closed

YearOffset issue #29827

cibic89 opened this issue Nov 24, 2019 · 1 comment

Comments

@cibic89
Copy link

cibic89 commented Nov 24, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
import_date_end = pd.to_datetime("2019-01-01")
import_date_end - pd.offsets.YearOffset(n=8, normalize=True, month=1)

Problem description

It's because the YearOffset month is Jan and so is the given month

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-50-1062b3c9831a> in <module>
      1 import_date_end# - pd.offsets.YearOffset(n=8, normalize=True, month=1)
----> 2 pd.to_datetime("2019-01-01") - pd.offsets.YearOffset(n=8, normalize=True, month=1)

pandas/_libs/tslibs/offsets.pyx in pandas._libs.tslibs.offsets.BaseOffset.__rsub__()

pandas/_libs/tslibs/offsets.pyx in pandas._libs.tslibs.offsets._BaseOffset.__add__()

~\miniconda3\envs\test\lib\site-packages\pandas\tseries\offsets.py in wrapper(self, other)
    110                 other = other.tz_localize(None)
    111 
--> 112             result = func(self, other)
    113 
    114             if self._adjust_dst:

~\miniconda3\envs\test\lib\site-packages\pandas\tseries\offsets.py in apply(self, other)
   1950     @apply_wraps
   1951     def apply(self, other):
-> 1952         years = roll_yearday(other, self.n, self.month, self._day_opt)
   1953         months = years * 12 + (self.month - other.month)
   1954         return shift_month(other, months, self._day_opt)

pandas/_libs/tslibs/offsets.pyx in pandas._libs.tslibs.offsets.roll_yearday()

pandas/_libs/tslibs/offsets.pyx in pandas._libs.tslibs.offsets.get_day_of_month()

NotImplementedError: 

Expected Output

Timestamp('2012-01-01 00:00:00')

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 79 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 0.25.3
numpy : 1.17.3
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 41.6.0.post20191030
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.6
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.9.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.2.6

@mroeschke
Copy link
Member

As the error states, this offset is not implemented.

Additionally in #7706, looks like we intend to eventually make this offset private, so I don't believe this offset is intended to work.

In the meantime, you can try to use DateOffset instead: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.tseries.offsets.DateOffset.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants