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

DatetimeIndex shift freq ValueError #27816

Closed
michal-demecki-profil-software opened this issue Aug 8, 2019 · 2 comments
Closed

DatetimeIndex shift freq ValueError #27816

michal-demecki-profil-software opened this issue Aug 8, 2019 · 2 comments

Comments

@michal-demecki-profil-software

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

@Liam3851
Copy link
Contributor

Liam3851 commented Aug 8, 2019

Appears to be a manifestation of #26258. I can reproduce on 0.24.2 but not on 0.25 or master. Please try upgrading to 0.25 and see if it fixes your issue.

@michal-demecki-profil-software
Copy link
Author

Thanks, works properly on 0.25.0

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