简体   繁体   English

15分钟间隔的csv条数据的每小时平均值

[英]Hourly Average of csv data of 15 minutes interval

My data in csv files is 15 minutes average and I want to hourly Average.我在 csv 个文件中的数据是平均 15 分钟,我想每小时平均一次。 When I used below code, it is showing error.当我使用下面的代码时,它显示错误。 'how' unrecognised argument. “如何”无法识别的论点。

import pandas as pd

df = pd.read_csv("sirifort_with_data.csv",parse_dates=['Time_Stamp'])
data.resample('H', how='mean')

Indeed, pandas.resample does not have a keyword argument named how .实际上, pandas.resample没有名为how的关键字参数。 You only use that function to group your time-series data.您仅使用 function 对时间序列数据进行分组。 After applying the function, you could apply another to apply operations on each sample/group.应用 function 后,您可以应用另一个对每个样本/组应用操作。 Since you want to calculate the average of each group, you can use .mean() :由于你想计算每组的平均值,你可以使用.mean()

data.resample('H').mean()
import pandas as pd

df = pd.read_csv("sirifort_with_data.csv")
df['Time_Stamp'] = pd.to_datetime(df['Time_Stamp'])
df = df.set_index('Time_Stamp').resample('H').mean()

After converting the Time_Stamp to pd.to_datetime, it worked fine.将 Time_Stamp 转换为 pd.to_datetime 后,它工作正常。 Thanks for the help.谢谢您的帮助。

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

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