如何索引熊猫系列中的单元格?

时间:2019-10-09 17:21:37

标签: python jupyter-notebook

我使用了这段代码

SERV_CODE  CPT_CODE
2110       90834      -600.000000
           90837      -421.000000
2111       90849      -110.000000
           90853      -130.000000
2220       90834      -800.000000
           90837      -416.534804
           90849      -110.000000

显示此表

{{1}}

如何索引第三列?

1 个答案:

答案 0 :(得分:0)

nonzero = ucla_all[ucla_all['ADJUSTMENTS']!= 0]
cond = (nonzero.groupby(['SERV_CODE', 'CPT_CODE']).mean())['ADJUSTMENTS']

cond.columns = ['SERV_CODE', 'CPT_CODE', 'NEW_COLUMN_NAME']
SERV_CODE  CPT_CODE   NEW_COLUMN_NAME
2110       90834      -600.000000
           90837      -421.000000
2111       90849      -110.000000
           90853      -130.000000
2220       90834      -800.000000
           90837      -416.534804
           90849      -110.000000