由于数据出现错误DataError: No numeric types to aggregate
改正以后才认识到astype的重要性。
Top15[
'populations'] = Top15[
'Energy Supply'].div(Top15[
'Energy Supply per Capita']).astype(float)
df_mean = ((df.set_index(
'Continent').groupby(level=0)[
'populations'].agg({
'mean' : np.mean})))
#加了astype(float)后无错误
转载于:https://www.cnblogs.com/Shinered/p/9242597.html