본문 바로가기
카테고리 없음

[pandas] sql distinct 처럼 unique한 column pair구하기

by 단창 2020. 4. 2.

two column의 고유한 pair 구하기 

  col1 col2
1 a b
2 d f
3 a b
4 a c
5 d f

df.groupby(['col1','col2']).size().reset_index(name='freq')

  col1 col2 freq
1 a b 2
2 d f 2
3 a c 1
반응형