-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
DatetimeDatetime data dtypeDatetime data dtypeRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Milestone
Description
From the pandas-dev mailing list:
I encountered a bug in pandas 1.1.0 after updating from 1.0.5 that I wanted to pass along. If a period range is created that extends past the maximum timestamp date of 2262-04-11, then the period range is shifted back by an hour after this date. The screenshots below show an example with the shifted times highlighted in yellow.
import pandas as pd
from datetime import datetime
start = datetime(2000, 1, 1)
end = datetime(2500, 1, 1)
idx = pd.period_range(start, end, freq="6H")
assert idx[-1].hour % 2 == 0 # raises
idx
# PeriodIndex(['2000-01-01 00:00', '2000-01-01 06:00', '2000-01-01 12:00',
# '2000-01-01 18:00', '2000-01-02 00:00', '2000-01-02 06:00',
# '2000-01-02 12:00', '2000-01-02 18:00', '2000-01-03 00:00',
# '2000-01-03 06:00',
# ...
# '2499-12-29 17:00', '2499-12-30 23:00', '2499-12-30 05:00',
# '2499-12-30 11:00', '2499-12-30 17:00', '2499-12-31 23:00',
# '2499-12-31 05:00', '2499-12-31 11:00', '2499-12-31 17:00',
# '2500-01-01 23:00'],
# dtype='period[6H]', length=730489, freq='6H')
pd.__version__
# '1.1.0'
Metadata
Metadata
Assignees
Labels
DatetimeDatetime data dtypeDatetime data dtypeRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version