我有多個具有相同列名的資料框。如何從所有資料框中獲取特定列的平均值(假設我想要獲取的列名是相似性)并將它們放入串列中?
DF1
similarity count
0 0.2 2
1 0.1 3
2 0.46 4
3 0.12 8
4 0.6 10
DF2
similarity count
0 0.2 4
1 0.1 3
2 0.46 5
3 0.12 6
4 0.6 9
預期產出
[ 0.296, 0.296 ]
uj5u.com熱心網友回復:
我會使用串列理解。
[df.similarity.mean() for df in [df1, df2]]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/489292.html
標籤:Python python-3.x 熊猫 数据框
下一篇:計算數字的位數總和時出現負數錯誤
