[英]how to find mean in rows of dataframe?
東風:
A B C D
1 2 3 la
0 1 -1 na
如何找到這樣的每一行的意思?:
A B C D mean
1 2 3 la 2
0 1 -1 na 0
我嘗試,但不是這樣(:
some_col = [A,B,C]
for col in some_col:
df['mean'] = [np.mean([x, y]) for x, y in zip(df[col], df['mean'])]
你應該試試這個:
df.mean(axis=1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.