我使用了这段代码
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}}
如何索引第三列?
答案 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