追加列总计到Pandas DataFrame [英] Appending column totals to a Pandas DataFrame
本文介绍了追加列总计到Pandas DataFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有数值的DataFrame.追加代表每列总和的行(具有给定的索引值)的最简单方法是什么?
I have a DataFrame with numerical values. What is the simplest way of appending a row (with a given index value) that represents the sum of each column?
推荐答案
要添加Total
列,该列是该行的总和:
To add a Total
column which is the sum across the row:
df['Total'] = df.sum(axis=1)
这篇关于追加列总计到Pandas DataFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文