## 컬럼명 level down
df_01_ag = df_01.groupby(["origin_bizpl_cd" , "goods_cd", "bizpl_goods_cd"] ).agg({"bg_purch_qty" : ["sum","mean"]})
# agg column level down
df_01_ag = df_01_ag.droplevel(0, axis= 1).reset_index()
## aggregation 컬럼명 변경
df_01_ag = df_01.groupby(["origin_bizpl_cd" , "goods_cd", "bizpl_goods_cd"] ).agg({"bg_purch_qty": [("sum", "sum"), ("mean", "mean"), ("max", "max")], "bg_purch_qty_yn":[("count", "sum")]})
df_01_ag = df_01_ag.droplevel(0, axis= 1).reset_index()
'언어 꿀Tip > Python 꿀tip!' 카테고리의 다른 글
07_01_14. 데이터 프레임에서 특정 값을 포함한 컬럼명 filter (0) | 2021.03.10 |
---|---|
07_01_13. 데이터프레임 공백 제거 strip() (0) | 2021.03.09 |
07_01_11. pickle 형태로 내보내기 / 불러오기 (0) | 2021.02.26 |
07_01_10. jupyter notebook terminal에서 폴더 삭제 (0) | 2021.02.22 |
07_01_08. seaborn x축 날짜 변경 (시계열 형태) (0) | 2021.02.09 |