Reputation: 728
I have a dataframe with 5 columns and 50k rows.all columns are int
except the date
that is date time
.
In this dataframe, data gathered for 1 year and there are multiple data for one day. i want to calculate the mean and variance of some columns for each day and put it in a new data frame.
Is there any pandas function or other way to do this?
Upvotes: 0
Views: 1472
Reputation: 17122
use groupby
, it will return a new dataframe for you.
df.groupby('date').mean()
df.groupby('date').std()
isolating columns:
df.groupby('date')['price_per_unit'].mean()
Upvotes: 4