import pandas as pd
url = 'https://ko.wikipedia.org/wiki/%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD%EC%9D%98_%EC%9D%B8%EA%B5%AC'
url
!pip install lxml
pd.read_html(url)
table=pd.read_html(url)
len(table)
df=table[1]
df.shape
plt.figure(figsize=(15,4)) #표의 크기 및 비율 조정
plt.xticks(rotation=60) # 글씨를 60도씩 돌려서 보일수 있도록
sns.pointplot(data=df,x='연도 (년)',y='사망자수(명)') #포인트 플롯으로 보기
plt.figure(figsize=(15,4))
plt.xticks(rotation=60)
sns.lineplot(data=df,x='연도 (년)',y='사망자수(명)') #라인플롯으로 보기
#한그레프에 두개의 데이터 표현하기
plt.figure(figsize=(15,4))
plt.xticks(rotation=60)
sns.pointplot(data=df,x='연도 (년)',y='출생자수(명)')
sns.pointplot(data=df,x='연도 (년)',y='사망자수(명)',color='orange')
df.columns
df_pop=df[['연도 (년)','출생자수(명)','사망자수(명)']]
df_pop=df_pop.set_index('연도 (년)')
df_pop.head()
df_pop[-50:].plot(figsize=(15,8)) #최근 50년 데이터만 확인하기
#seaborn으로 최근 50년 데이터 그리기
plt.figure(figsize=(15,4))
plt.xticks(rotation=60)
sns.pointplot(data=df[-50:],x='연도 (년)',y='출생자수(명)')
sns.pointplot(data=df[-50:],x='연도 (년)',y='사망자수(명)',color='orange')
plt.figure(figsize=(15,4))
plt.xticks(rotation=60)
sns.lineplot(data=df[-50:],x='연도 (년)',y='출생자수(명)')
sns.lineplot(data=df[-50:],x='연도 (년)',y='사망자수(명)',color='orange')
#barplot 으로 그리기
plt.figure(figsize=(15,4))
plt.xticks(rotation=60)
sns.barplot(data=df[-50:],x='연도 (년)',y='출생자수(명)')
sns.barplot(data=df[-50:],x='연도 (년)',y='사망자수(명)',palette='Blues')
'First step > AI 기초반' 카테고리의 다른 글
[TIL]21.07.21openCV 기초 (0) | 2021.07.21 |
---|---|
[TIL]21.07.20TCP/IP 기초 예외처리 (0) | 2021.07.20 |
[TIL]21.07.19 비지도학습 (0) | 2021.07.19 |
[TIL]21.07.16 케라스 실습 선형회귀 데이터 (0) | 2021.07.17 |
[TIL]21.07.15과적합 (0) | 2021.07.15 |