我相信您是在问是否有没有指定年份的日期时间这样的对象。好像没有。 Period 对象总是指定年份:使用它们不会节省内存。
t=pd.Period('03-04',freq='D')
t.year==1
t.month==3
t.day==4
您应该使用 dateTime 对象并忽略它们所在的年份。唯一的障碍是闰年。对于初学者,您可以选择距任何闰年 2 年的年份,或参考 Timestamps.isocalender 值,使用类似的策略选择起始年份,使您的年份距最近的 12 年有 53 周(isocalendar 有一个固定的精确 52周,每 24 年有 53 周(7 天/周 * 4 年/addLeapDay)。
TDate15.Date=[d.replace(year=1904) for d in TDate15.Date]#
TDate15=TDate15.groupby('Date').agg({'Data_Value':['min','max']})
#vs
TDate15=TDate15.groupby([d2015.Date.dt.month,d2015.Date.dt.day]).agg({'Data_Value':['min','max']})
#if you use a reference year as in the first exemple, you get an index of Datetime.
#vs
#using directly groupby day & month, you might need to convert to datetime further, wich would looked at least like:
#TDate15.index=[pd.to_datetime(d,m) for m,d in TDate15.index]
#However I had to do:
i=list(zip(TDate15.index.labels[0],TDate15.index.labels[1]))
x=[pd.to_datetime( str(TDate05.index.levels[0][m]) + '-' + str(TDate05.index.levels[1][d]) +'-' + '1904',
format='%m-%d-%Y') \
for m,d in i]
我看到的完整解决方案是通过使其始终回到相同的非闰年来调整日期时间类。
对于合并或分组,strftime 一次性完成这项工作。输出是字符串,因此对于多个 manip,您需要来回转换字符串日期时间。
我希望您不会因为“年份”而对使用的内存空间有真正的问题。