-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: date_range returns wrong output in some cases #35342
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
I will try to fix this problem |
I think this problem come with |
and the error occured on code |
change some issues be metioned at pandas-dev#35342
fix issues be metioned at pandas-dev#35342
The issue here is in core.arrays.datetimes.generate_range in the lines
"2020-05-12 13:00" is getting rolled back to "2020-05-01 13:00" |
I'm having the same issue under a different usage. I'm currently splitting a query constrained by a start and end timestamps into smaller chunks and using date_range to get the start and end of the subqueries. For example:
Returns: I was expecting |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Currently outputs:
Problem description
Seems that if
freq
='MS', the date ofstart
is the first day of a month, and the time ofstart
is after the time ofend
, then the last month is missing from the output.The same problems seems to also occur if
freq
='M' and the date ofstart
is the last day of a month (and the time ofstart
is after the time ofend
), as demonstrated below.(Perhaps the problem could occur also with other values of the
freq
parameter. However, I only tested with 'MS' and 'M'.)Expected Output
I would expect every code line above to produce the following output:
Another code Sample, a copy-pastable example
Here is an example with
freq
='M'.Expected Output
Here the expect output of each code line above is:
Output of
pd.show_versions()
(While the below output reports pandas version 1.0.3, i have also tested with version 1.0.5 with same results.)
INSTALLED VERSIONS
commit : None
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 5.3.0-62-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fi_FI.UTF-8
LOCALE : fi_FI.UTF-8
pandas : 1.0.3
numpy : 1.19.0
pytz : 2019.3
dateutil : 2.8.1
pip : 9.0.1
setuptools : 46.1.3
Cython : 0.29.20
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 0.9.6
lxml.etree : 4.2.1
html5lib : 0.999999999
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 5.5.0
pandas_datareader: None
bs4 : 4.6.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.2.1
matplotlib : 3.2.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.5.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.1.0
xlwt : None
xlsxwriter : 0.9.6
numba : None
The text was updated successfully, but these errors were encountered: