我想从一个列表中总结出一个特定数量的数字
openBids = df_1['openBid']
mean = np.mean(openBids)
std = np.std(openBids)
rets = np.log(openBids / openBids.shift(1))
rets.dropna()
round(sum(rets.dropna()), 4) # here i only want to add together the first ten numbers from the list for example
有人能告诉我怎么做吗
谨致问候
马塞尔
可以使用python的列表切片(假设
rets.dropna()
返回一个列表)rets.dropna()[:10]
将是列表中的前十个有关此语法的更多示例,请参见python docs tutorial
相关问题 更多 >
编程相关推荐