我得到了以下DF:http://prntscr.com/f72cbm
def answer():
Top15 = one()
timefr = ['2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015']
rng = range(0, 9)
for i in rng:
for k,v in Top15[timefr].iloc[[i]].iteritems():
print(k, v)
函数返回许多以下类型的序列:
2006 Country
China 3.992331e+12
Name: 2006, dtype: float64
2007 Country
China 4.559041e+12
Name: 2007, dtype: float64
年份、国家名称、价值。
我可能会遍历每个系列,将所有值相加,然后将它们除以等等,但是有没有更“潘多拉”的方法呢?
我还想跳过NaN值
如果我没看错问题,你只需要
df.mean(axis=1)
;例如相关问题 更多 >
编程相关推荐