4
我有一個熊貓DateTimeIndex。我想在每個日期添加十五天。在大熊貓的每個日期添加15天DatetimeIndex
import pandas as pd
tidx = pd.date_range(end='2016-04-30', freq='M', periods=2)
tidx
DatetimeIndex(['2016-03-31', '2016-04-30'], dtype='datetime64[ns]', freq='M')
我想:
DatetimeIndex(['2016-04-15', '2016-05-15'], dtype='datetime64[ns]', freq=None)
我做:
pd.to_datetime([pd.datetime(t.year, t.month + 1, 15) for t in tidx])
這隻要t.month + 1
是大於12打破了有沒有做日期普遍接受的好辦法數學在整個系列?