is there a way to generate dates for 10000 years ? starting from 1-1-1 to 9999-12-31

Viewed 56

I have used pandas function to create dates with this period of time, but it returned empty list.

date_df = pd.date_range(start='1/1/1', end='31/12/1999')
1 Answers

Timestamps in Pandas have a min and a max:

pd.Timestamp.min
# Timestamp('1677-09-21 00:12:43.145224193')

pd.Timestamp.max
# Timestamp('2262-04-11 23:47:16.854775807')

See further: What determines Pandas minimum and maximum timestamp?. What you could do, is use pd.period_range() instead. So:

period_index = pd.period_range(start='0001-01-01', end='9999-12-31')
print(period_index)

PeriodIndex(['0001-01-01', '0001-01-02', '0001-01-03', '0001-01-04',
             '0001-01-05', '0001-01-06', '0001-01-07', '0001-01-08',
             '0001-01-09', '0001-01-10',
             ...
             '9999-12-22', '9999-12-23', '9999-12-24', '9999-12-25',
             '9999-12-26', '9999-12-27', '9999-12-28', '9999-12-29',
             '9999-12-30', '9999-12-31'],
            dtype='period[D]', length=3652059)
Related