python 2.7 - Why is day of pandas date_range not what I specified? -
why first date not 4/19/1965? why day 30 instead of 19?
dates = pd.date_range('1965-04-19', freq='6m', periods=3) dates[0] timestamp('1965-04-30 00:00:00', offset='6m')
it looks default behavior freq='m'
monthend()
, so
dates = pd.date_range('1965-04-19', periods=3, freq='6m') dates datetimeindex(['1965-04-30', '1965-10-31', '1966-04-30'], dtype='datetime64[ns]', freq='6m', tz=none)
this can changed setting freq = pd.tseries.offsets.dateoffset(months=6)
.
dates = pd.date_range('1965-04-19', periods=3, freq=pd.tseries.offsets.dateoffset(months=6)) dates datetimeindex(['1965-04-19', '1965-10-19', '1966-04-19'], dtype='datetime64[ns]', freq='<dateoffset: kwds={'months': 6}>', tz=none)
Comments
Post a Comment