试图通过有效的方式将数据帧按日期范围分开,到目前为止,我只想到:
mask0 = df['Date of survey'].between('2010-01-01', '2010-12-31')
mask1 = df['Date of survey'].between('2011-01-01', '2011-12-31')
mask2 = df['Date of survey'].between('2012-01-01', '2012-12-31')
...
maskn = df['Date of survey'].between('nnnn-01-01', 'nnnn-12-31')
任何想法都将不胜感激! (我将使用掩码对数据帧进行子集划分,并获得每年每个列变量的平均和)
这里更好的方法是将^{} 按年份与
mean
和sum
等聚合函数一起使用:或使用^{} 年^{} :
相关问题 更多 >
编程相关推荐