I want to use .groupby().mean() on this DataFrame, however, it doesn't omit the NaN values.
Here is the picture of my DataFrame
'Quarters' is my last row so I do transpose to make it the last column, and groupby 'Quarters', then do .mean() for all the counties. I expect to store the new DataFrame in a new variable, with column indexes as county names, and row indexes as 'Quarters', each cell is the mean of 3 cells that share the same County and same 'Quarters' in the previous DataFrame.
So I do:
ANSWER = City_Zhvi_AllHomes.T.groupby('Quarters').mean().T
But I got:
DataError: No numeric types to aggregate
It will work if I do .fillna(0) before .groupby(), here is the picture for that (except I transpose the row and column again)
But I can't do that since it will affect the result for the mean. So what should I do to tell .mean() to ignore NaN?