metalrules211
metalrules211

Reputation: 197

Calculating daily averages in pd.Series

I have a Dataframe series with 30s frequency.

df.head()

enter image description here

I want to calculate the daily averages for all signals in that series but it doesnt seem to work. I tried both

df_average = df.to_period('D')
df.resample('D')

And i get: enter image description here

I want to have only 1 line per day. Why do i get more? Thank you

Upvotes: 1

Views: 106

Answers (2)

wwnde
wwnde

Reputation: 26676

@jezrael is sure way to go. Could also try;

df.groupby(df.index.date).mean()

Upvotes: 0

jezrael
jezrael

Reputation: 862641

If there is DatetimeIndex only add an aggregate function, here mean, to resample:

df1 = df.resample('D').mean()

Upvotes: 3

Related Questions