728x90
반응형
데이터를 퍼센테이지로 비교해서 보고 싶을때 사용
generation_id 별로 데이터의 갯수를 퍼센테이지로 비교할 수 있도록 파이차트로 나타내보자!
df2 = df['generation_id'].value_counts()
plt.pie(df2, labels=df2.index, autopct='%.1f', startangle=90, wedgeprops={'width':0.7})
plt.legend()
plt.title('Generation ID Pie Chart')
# %.2f : 소수점 2자리까지 퍼센트로 나타내라
# wedgeprops={'width':0.7} : 가운데 구멍 뚫기(도넛모양)
plt.show()
type_1 의 데이터를 보니까 총 18개인데 데이터의 갯수가 가장 많은 순으로 상위 6개만 카운트 플롯하시오
df['type_1'].nunique()
type1 = df['type_1'].value_counts().head(6).index
sb.countplot(data=df, y='type_1', order=type1)
plt.show()
type2 = df['type_1'].value_counts().index[ : 5+1 ]
sb.countplot(data=df, y='type_1', order=type2)
plt.show()
generation_id 값은 1부터 7까지 총 7개 인데 상위 4개만 파이 차트로 나타내시오
data1 = df['generation_id'].value_counts().head(4)
plt.pie(data1, labels=data1.index, autopct='%.2f', startangle=90)
plt.show()
data2 = df['generation_id'].value_counts()
data2 = data2[: 3+1]
plt.pie(data2, labels=data2.index, autopct='%.1f', startangle=90, wedgeprops={'width':0.7})
plt.legend()
plt.show()
728x90
반응형
'즐거운프로그래밍' 카테고리의 다른 글
[python] seaborn 차트(Bar Chart, 바 차트) 예제 (1) | 2023.11.17 |
---|---|
[python] seaborn 차트 만들기(Bar Chart, 바 차트) (1) | 2023.11.17 |
[python] Matplotlib 차트 만들기(Line Chart, 라인 차트) (0) | 2023.11.17 |
[pandas] pandas CONCATENATING AND MERGING (0) | 2023.11.16 |
[pandas] pandas SORTING AND ORDERING (0) | 2023.11.16 |