Screen Link:
https://app.dataquest.io/m/137/data-cleaning-walkthrough%3A-combining-the-data/5/computing-average-class-sizes
My Code:
import numpy
grouped= class_size.groupby("DBN")
grouped-grouped.mean()
grouped.reset_index(inplace=True)
data["class_size"] = grouped
print(data["class_size"].head())
What I expected to happen:
I tried using groupby.mean() method as explained in Learn data science with Python and R projects but I am getting the error.
What actually happened:
Unable to coerce to Series, length must be 7: given 583
As shown in Learn data science with Python and R projects we use grouby.agg() method when we want to apply more than one aggregate method. But in this case, we only want to calculate mean() for all columns so why is groupby.mean() giving me this error?