2019. 12. 15. 15:17ㆍPython programming
1. 수직 바그래프
Series.plot.bar() method
관련 문서 : https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.plot.bar.html
2.수평 바그래프 Series.plot.barh()
test = wnba['Exp_ordinal'].value_counts().iloc[[3,0,2,1,4]]
test.plot.barh()
3. 파이 그래프
Series.plot.pie()
예를 들어, wnba['Pos'].value_counts().plot.pie()
wnba['Exp_ordinal'].value_counts().plot.pie(figsize =(6,6), autopct = '%.2f%%', title='Percentage of players in WNBA by level of experience')
plt.ylabel('')
- string_format과 관련된 글 : https://docs.python.org/3/library/string.html#format-specification-mini-language

- autopct : 자동으로 백분율 비중 계산해주는 옵션
관련 설명 https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html
4. 히스토그램
- histogram의 구간interval 설정하기
Series.plot.hist(bin=#)
x축을 1부터 32까지 4씩 잘라서 8개를 만들어라
wnba['Games Played'].plot.hist(range = (1,32), bins = 8, title='The distribution of players by games played')
plt.xlabel('Games played')
5. 변수별 visualization

6. grouped bar plot
import seaborn as sns
sns.countplot() <---관련문서는 여기
seaborn.countplot — seaborn 0.9.0 documentation
x, y, hue : names of variables in data or vector data, optional Inputs for plotting long-form data. See examples for interpretation. data : DataFrame, array, or list of arrays, optional Dataset for plotting. If x and y are absent, this is interpreted as wi
seaborn.pydata.org
예시)
# x= 그룹화하고싶은 컬럼 (ex: 여성,남성)
# hue = 색깔
# data = y축
import seaborn as sns
sns.countplot(x='Exp_ordinal', hue='Pos', data=wnba , order = ['Rookie', 'Little experience', 'Experienced', 'Very experienced', 'Veteran'],
hue_order = ['C', 'F', 'F/C', 'G', 'G/F'] )
7. Histogram을 smoothing 시키기
- kernel density estimate plot 이라고 부름
Series.plot.kde() function --> 관련 문서는 여기
pandas.Series.plot.kde — pandas 0.25.3 documentation
Parameters: bw_method : str, scalar or callable, optional The method used to calculate the estimator bandwidth. This can be ‘scott’, ‘silverman’, a scalar constant or a callable. If None (default), ‘scott’ is used. See scipy.stats.gaussian_kde for more inf
pandas.pydata.org
- 이 외에도 많은 seaborn

'Python programming' 카테고리의 다른 글
Transforming Data With Pandas (0) | 2020.01.18 |
---|---|
기초통계 : 평균, 분산 (1) | 2019.12.21 |
★★pandas - pd.concat()와 pd.merge(), 문자 데이터 다루기 Working With Strings In Pandas (데이터 클렌징시 유용) (0) | 2019.11.27 |
그래프를 그려요 - matplotlib (0) | 2019.11.25 |
Pandas 를 써봐요 (0) | 2019.11.23 |