我比平时更新,从一位同事继承了一部法典,我似乎无法操作。 设想是,在数据框架中增加一个总行和一栏,但该栏的行目并不奏效,并造成多种错误(见许多“背后(最近的最后一次通话)”):
<代码>csmposting = 产生_csm_table(csm) csmposting [ Total] = csmposting.sum(axis=1) ->这一行文造成错误的贴出错。
当我没有这条线时,我会发现(我去除一栏头):
Unit1 779 285 16 2 3
Unit2 290 20 3 3 0
Unit3 0 0 3 7 0
Unit4 547 97 8 10 0
TOTAL 1616 402 30 22 3
I ve tried changing that line to:
csmposting.loc[ TOTAL1 ] = csmposting.sum(axis=1)
This only ends up adding it as another row at the bottom of the table and adds a decimal place to all the numbers:
Unit1 779.0 285.0 16.0 2.0 3.0
Unit2 290.0 20.0 3.0 3.0 0.0
Unit3 0.0 0.0 3.0 7.0 0.0
Unit4 547.0 97.0 8.0 10.0 0.0
TOTAL1 NaN NaN NaN NaN NaN
TOTAL 1616.0 402.0 30.0 22.0 3.0
是否有任何人建议如何使整栏显示和保持编号格式不变?
谢谢!