pandas astype()错误

时间:2018-06-29 11:39:57   收藏:0   阅读:546

由于数据出现错误
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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!