-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
date_range fails when I try to generate ones with 1 periods and freq equal WOM-1MON #20517
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
Comments
Well the traceback here points exactly to the offending line of code - within the constructor there is an explicit check that you have more than one period which I've linked below for reference ( pandas/pandas/tseries/offsets.py Line 1464 in c4b4a81
If you remove that assertion you get the value you are expecting. I'm not overly familiar with offsets though - @jbrockmendel any chance you know whether it makes sense to relax that assertion or not? |
This is one of those "it was like that when I got here" things. I'd guess that n==0 would cause trouble with incrementing, but not really sure. |
@mmngreco do you want to try a PR for this? Would need test cases to cover this and any other edge case you can think of |
Ok, I would like to try. |
The same check can be found for three other offsets: import pandas as pd
from pandas.tseries.offsets import *
# all three lines below return ValueError: N cannot be 0
pd.date_range('20100104', periods=1, freq=LastWeekOfMonth(weekday=2))
pd.date_range('20100104', periods=1, freq=FY5253(startingMonth=4, weekday=2, variation='nearest'))
pd.date_range('20100104', periods=1, freq=FY5253Quarter(qtr_with_extra_week=1, startingMonth=4, weekday=2, variation='nearest'))
pandas/pandas/tseries/offsets.py Lines 1538 to 1539 in 601b8c9
pandas/pandas/tseries/offsets.py Lines 1824 to 1825 in 601b8c9
pandas/pandas/tseries/offsets.py Lines 2025 to 2026 in 601b8c9
|
Code Sample
Problem description
If N is equal to periods then is not 0 as we can see, that make me think that probably there is something wrong in the code.
Expected Output
Output of
pd.show_versions()
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Darwin
OS-release: 17.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None
LOCALE: es_ES.UTF-8
pandas: 0.22.0
pytest: 3.4.2
pip: 9.0.1
setuptools: 38.5.1
Cython: 0.27.3
numpy: 1.14.2
scipy: 1.0.0
pyarrow: 0.9.0
xarray: 0.10.2
IPython: 6.2.1
sphinx: 1.7.1
patsy: 0.5.0
dateutil: 2.7.0
pytz: 2018.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.2.2
openpyxl: 2.5.1
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 1.0.2
lxml: 4.2.0
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.5
pymysql: 0.8.0
psycopg2: None
jinja2: 2.10
s3fs: 0.1.3
fastparquet: 0.1.4
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: