Description
Code Sample, a copy-pastable example if possible
dt = pd.date_range('2017-01-01', '2020-01-01', name='date', freq='D')
df = pd.DataFrame(pd.np.random.rand(dt.shape[0]), index=dt)
df.shift(-1, freq=pd.DateOffset(years=1))
Problem description
This code raise ValueError: Inferred frequency None from passed values does not conform to passed frequency D
while date range from '2018-01-01' works perfectly fine.
Expected Output
Dataframe with properly shifted index.
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-55-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.2
pytest: 5.0.1
pip: 10.0.1
setuptools: 41.0.1
Cython: 0.29.10
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.4.0
sphinx: None
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.3
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: None
lxml.etree: 4.3.4
bs4: None
html5lib: None
sqlalchemy: 1.3.2
pymysql: None
psycopg2: 2.8.3 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: 0.3.1
pandas_gbq: None
pandas_datareader: None
gcsfs: None