简体   繁体   English

将 15 分钟数据重新采样为 30 分钟

[英]Resampling 15 minutes data to 30minutes

Im using the resampling function in pandas to sum up two 15 minutes interval data into 30 minutes interval data for a data frame.我使用pandas中的重采样功能将两个15分钟间隔的数据汇总为一个数据框的30分钟间隔数据。 it works but the answer i get is just that for the results recorded at the 30th minutes , not the addition of the recorded results at the 15th and the 30th minute.它有效,但我得到的答案只是第 30 分钟记录的结果,而不是第 15 分钟和第 30 分钟记录结果的相加。 Any help please?请问有什么帮助吗?

Below is the code i used for the resampling and the results for that: series["30mins"]= series.resample('2T',label="right",closed="right").sum() time 15 mins rainfall 30mins 2020-09-13 06:45:00 2.587 nan 2020-09-13 07:00:00 2.621 2.621 2020-09-13 07:15:00 1.617 nan 2020-09-13 07:30:00 5.748 5.748下面是我用于重采样的代码和结果: series["30mins"]= series.resample('2T',label="right",closed="right").sum() 时间 15 分钟降雨30 分钟 2020-09-13 06:45:00 2.587 南 2020-09-13 07:00:00 2.621 2.621 2020-09-13 07:15:00 1.617 南 07:0304 07:08-2020

Instead of using series["30mins"]= series.resample('2T',label="right",closed="right").sum()而不是使用series["30mins"]= series.resample('2T',label="right",closed="right").sum()

try尝试

series["30mins"]= series.resample('2T').agg({'column name': 'sum'})

It worked for me.它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM