My data in csv files is 15 minutes average and I want to hourly Average. 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')
CodePudding user response:
Indeed, pandas.resample
does not have a keyword argument named how
. You only use that function to group your time-series data. After applying the function, you could apply another to apply operations on each sample/group. Since you want to calculate the average of each group, you can use .mean()
:
data.resample('H').mean()
CodePudding user response:
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. Thanks for the help.