发布时间:2019-09-18 07:27:52编辑:auto阅读(3910)
以下是利用Python进行数据分析中低十章对resample方法具体解释,不过how参数已经过时
#把流量数据每3分钟聚合一次
def flowdata_fusion_3(temp_volume_series, temp_time_series):
# print(temp_volume_series)
temp_volume_series.index = temp_time_series
ts = pd.Series(temp_volume_series)
flowdata_fusion_3min = ts.resample('3min', label='left', closed='left').sum()
# print(date_fusion_3min)
return flowdata_fusion_3min
temp_volume_series代表这检测器获取的数流量,是Series格式,它的默认索引是0~~xx,想把它的索引改为流量对应的时间格式
之前用的是pd.Series(temp_volume_series).reindex(temp_time_series)
或者pd.Series(temp_volume_series,index=temp_time_series),但是结果聚合后,流量值全都变为NAN。这两种方式只是重排,说白了就是重新创建了新的的索引,但是流量数据还在默认的索引中,所以新的流量不存在就用NAN代替。
解决方法:
直接获取它全部的索引值强制改变 temp_volume_series.index = temp_time_series
上一篇: python 读取文件乱码问题
下一篇: python 收集主机信息
48986
48123
38862
35995
30409
27186
26178
21016
20855
19211
58°
78°
69°
746°
813°
792°
803°
780°
729°
863°