我有从1992年到2016年的1D月度数据。我想取1992-2016年所有一月值的平均值,以便分离季节变化。我的for循环做得对吗
test_mean = []
for months in range(lsds_detrend_mnths.size):
mean = np.mean(lsds_detrend_mnths[months::months+1])
test_mean.append(mean)
我是否正确使用阵列切片
或者为了计算所有年份中每个月的平均值,我是否为循环计算这个值
Tags:
如果您的数据从1月开始,则应使用此值获得1月的平均值:
mean = np.mean(lsds_detrend_mnths[::12])
这将是一月份的平均值。要获得其他月份的平均值,您可以使用以下循环:
请记住切片表示法的含义:
a[start:stop:step] # start through not past stop, by step
相关问题 更多 >
编程相关推荐