我有一个包含 1000 行和 10 列(price_list)的数组。随着命令
price_list.mean(axis = 1)
我对每一行执行了平均值。如何使用循环来执行相同的计算?非常感谢你。
例子:
In: price_list
Out: array([[ 88.118629 , 88.118629 , 88.118629 , ..., 88.118629 ,
88.118629 , 88.118629 ],
[ 87.89849451, 88.28521857, 87.88550764, ..., 88.63412578,
88.10322998, 88.88926288],
[ 88.65587777, 87.76942845, 88.48962856, ..., 88.2796555 ,
88.63031452, 88.88182671],
...,
[ 65.34289835, 66.92005094, 90.12852383, ..., 167.15607114,
226.66403648, 130.07803463],
[ 65.55047596, 66.5069593 , 88.99919496, ..., 164.45858893,
229.17325779, 129.15578263],
[ 64.71865904, 66.40562405, 88.06256922, ..., 161.90378821,
227.48460064, 127.58404374]])
In: price_list_new = price.list.mean(axis = 1)
Out: array([ 88.118629 , 88.35964886, 88.36762515, 88.82571439,
89.15239399, 88.74944235, 88.82604126, 88.48155552,
88.70669718, 88.87349793, 88.49569989, 88.3928375 ,
88.44854633, 88.38734393, 88.51877214, 88.53055382,
88.47660207, 88.08328303, 88.05407612, 87.73566519,
88.10523588, 87.72906819, 87.53641688, 87.5564761 ,
87.4484196 , .............])
白板的微信
莫回无
相关分类