pandas에서 항목별 개수를 세고 matplotlib없이 바로 histogram을 그릴 수 있다.
다음과 같은 데이터가 있다고 하자.
data.shape
>>> (610292,1)
data
>>>
col
0 a
1 a
2 a
3 a
4 a
5 a
6 b
7 a
8 b
9 a
10 c
11 b
12 a
...
아래 코드로 항목별 개수 그래프를 생성할 수 있다.
CountStatus = pd.value_counts(data['col'].values, sort=True)
CountStatus.plot.bar()
CountStatus.plot.bar(grid=True, figsize=(10,8), fontsize=15) # figsize, fontsize 조정
728x90
'python 메모' 카테고리의 다른 글
[python] any(), all() (0) | 2021.05.06 |
---|---|
[pandas] DataFrame을 string으로 출력하기 (0) | 2021.04.15 |
[python] url로 json 데이터 받아오기 (0) | 2021.03.31 |
[tqdm] tqdm에서 새로운 라인 없이 한 라인으로 출력하기 (2) | 2021.03.24 |
[numpy] stack 결과 (0) | 2021.03.17 |