반응형

@notepad_jj2

츄르사려고 코딩하는 코집사입니다.


 

 

 

In [94]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from matplotlib import font_manager, rc
In [95]:
#plot 한글 깨짐
plt.rc('font', family='Malgun Gothic')

#막대그래프 한글 깨짐
font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()
rc('font', family=font_name)
In [96]:
AI_최종데이터 = pd.read_csv('C:/Users/User/Desktop/AI data/AI_최종데이터.csv', encoding="CP949")
In [97]:
AI_최종데이터
Out[97]:
  시군 발생연도 발생월 축종 평균기온 최저기온 최고기온 평균풍속 평균상대습도 일교차 철새도래지거리
0 충청남도 아산시 2018 3 5.6 -2.9 14.4 1.5 58.8 17.3 8582.397046
1 경기도 평택시 2018 3 5.5 -0.3 9.4 3.5 67.6 9.7 8966.784833
2 경기도 양주시 2018 3 4.8 -1.0 10.3 2.7 57.5 11.3 1374.739109
3 충청북도 음성군 2018 3 오리 12.2 7.8 14.8 0.8 90.8 7.0 22033.033100
4 충청남도 천안시 2018 2 -5.8 -14.6 3.2 0.8 55.3 17.8 3023.783302
... ... ... ... ... ... ... ... ... ... ... ... ...
937 경상북도 경주시 2003 12 8.4 4.6 14.1 7.6 47.5 9.5 12675.870810
938 전라남도 나주시 2003 12 오리 -0.5 -6.8 5.0 4.0 68.1 11.8 8021.462978
939 충청북도 음성군 2003 12 -4.7 -7.1 -1.3 4.3 46.1 5.8 26746.211120
940 충청북도 음성군 2003 12 오리 0.1 -3.5 2.3 3.2 63.9 5.8 26814.818890
941 충청북도 음성군 2003 12 -1.2 -5.3 3.5 1.4 74.5 8.8 25511.467720

942 rows × 12 columns

 

sns.countplot()으로도 아래 코드 돌릴 수 있음

In [98]:
#발생연도 시각화 처리
발생연도_df = pd.DataFrame(pd.value_counts(AI_최종데이터['발생연도'], sort=False))
발생연도 = list(발생연도_df.index)
발생연도_count = list(발생연도_df['발생연도'])
In [99]:
#발생연도에 따른 빈도수 bar 그래프
sns.barplot(x=발생연도, y=발생연도_count)
plt.ylim(0,350)
plt.title('발생연도에 따른 빈도수')
plt.xlabel('발생연도')
plt.ylabel('빈도수')
plt.show()
 
In [100]:
fig = plt.figure(figsize=(20,20))
sns.countplot(x = '도', data = AI_최종데이터)
plt.title('도에 따른 빈도수')
plt.xlabel('도')
plt.ylabel('빈도수')
plt.show()
 
In [101]:
fig = plt.figure(figsize=(20,20))
sns.countplot(x = '시군', data = AI_최종데이터)
plt.title('시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
 
In [102]:
충청남도 = AI_최종데이터['도'] == '충청남도'
충청남도 = AI_최종데이터[충청남도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 충청남도)
plt.title('충청남도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[102]:
Text(0, 0.5, '빈도수')
 
In [103]:
충청북도 = AI_최종데이터['도'] == '충청북도'
충청북도 = AI_최종데이터[충청북도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 충청북도)
plt.title('충청북도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[103]:
Text(0, 0.5, '빈도수')
 
In [104]:
전라남도 = AI_최종데이터['도'] == '전라남도'
전라남도 = AI_최종데이터[전라남도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 전라남도)
plt.title('전라남도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[104]:
Text(0, 0.5, '빈도수')
 
In [105]:
전라북도 = AI_최종데이터['도'] == '전라북도'
전라북도 = AI_최종데이터[전라북도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 전라북도)
plt.title('전라북도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[105]:
Text(0, 0.5, '빈도수')
 
In [106]:
경상남도 = AI_최종데이터['도'] == '경상남도'
경상남도 = AI_최종데이터[경상남도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 경상남도)
plt.title('경상남도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[106]:
Text(0, 0.5, '빈도수')
 
In [107]:
경상북도 = AI_최종데이터['도'] == '경상북도'
경상북도 = AI_최종데이터[경상북도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 경상북도)
plt.title('경상북도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[107]:
Text(0, 0.5, '빈도수')
 
In [108]:
강원도 = AI_최종데이터['도'] == '강원도'
강원도 = AI_최종데이터[강원도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 강원도)
plt.title('강원도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[108]:
Text(0, 0.5, '빈도수')
 
In [109]:
경기도 = AI_최종데이터['도'] == '경기도'
경기도 = AI_최종데이터[경기도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 경기도)
plt.title('경기도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[109]:
Text(0, 0.5, '빈도수')
 
In [110]:
광주광역시 = AI_최종데이터['도'] == '광주광역시'
광주광역시 = AI_최종데이터[광주광역시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 광주광역시)
plt.title('광주광역시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[110]:
Text(0, 0.5, '빈도수')
 
In [111]:
대구광역시 = AI_최종데이터['도'] == '대구광역시'
대구광역시 = AI_최종데이터[대구광역시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 대구광역시)
plt.title('대구광역시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[111]:
Text(0, 0.5, '빈도수')
 
In [112]:
부산광역시 = AI_최종데이터['도'] == '부산광역시'
부산광역시 = AI_최종데이터[부산광역시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 부산광역시)
plt.title('부산광역시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[112]:
Text(0, 0.5, '빈도수')
 
In [113]:
서울특별시 = AI_최종데이터['도'] == '서울특별시'
서울특별시 = AI_최종데이터[서울특별시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 서울특별시)
plt.title('서울특별시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[113]:
Text(0, 0.5, '빈도수')
 
In [114]:
세종특별자치시 = AI_최종데이터['도'] == '세종특별자치시'
세종특별자치시 = AI_최종데이터[세종특별자치시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 세종특별자치시)
plt.title('세종특별자치시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[114]:
Text(0, 0.5, '빈도수')
 
In [115]:
울산광역시 = AI_최종데이터['도'] == '울산광역시'
울산광역시 = AI_최종데이터[울산광역시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 울산광역시)
plt.title('울산광역시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[115]:
Text(0, 0.5, '빈도수')
 
In [116]:
인천광역시 = AI_최종데이터['도'] == '인천광역시'
인천광역시 = AI_최종데이터[인천광역시]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 인천광역시)
plt.title('인천광역시의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[116]:
Text(0, 0.5, '빈도수')
 
In [117]:
제주특별자치도 = AI_최종데이터['도'] == '제주특별자치도'
제주특별자치도 = AI_최종데이터[제주특별자치도]

fig = plt.figure(figsize=(10,10))
sns.countplot(x = '시군', data = 제주특별자치도)
plt.title('제주특별자치도의 시군에 따른 빈도수')
plt.xlabel('시군')
plt.ylabel('빈도수')
plt.show()
Out[117]:
Text(0, 0.5, '빈도수')
 
In [31]:
#발생월 시각화 처리
발생월_df = pd.DataFrame(pd.value_counts(AI_최종데이터['발생월'], sort=False))
발생월 = list(발생월_df.index)
발생월_count = list(발생월_df['발생월'])
In [32]:
#발생월에 따른 빈도수 bar 그래프
sns.barplot(x=발생월, y=발생월_count)
plt.ylim(0,300)
plt.title('발생월에 따른 빈도수')
plt.xlabel('발생월')
plt.ylabel('빈도수')
plt.show()
 
In [33]:
#축종 시각화 처리
축종_df = pd.DataFrame(pd.value_counts(AI_최종데이터['축종'], sort=False))
축종 = list(축종_df.index)
축종_count = list(축종_df['축종'])
In [34]:
#축종에 따른 빈도수 bar 그래프
sns.barplot(x=축종, y=축종_count)
plt.title('축종에 따른 빈도수')
plt.xlabel('축종')
plt.ylabel('빈도수')
plt.show()
 
In [37]:
#평균기온에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['평균기온'])
Out[37]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fdebe7c0>
 
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0.0, flags=flags)
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0, flags=flags)
 
In [38]:
#최저기온에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['최저기온'])
Out[38]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fe094af0>
 
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0.0, flags=flags)
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0, flags=flags)
 
In [39]:
#최고기온에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['최고기온'])
Out[39]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fe121880>
 
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0.0, flags=flags)
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0, flags=flags)
 
In [41]:
#평균 풍속에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['평균풍속'])
Out[41]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fe1cdc10>
 
In [42]:
#평균 상대습도에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['평균상대습도'])
Out[42]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fe2a5bb0>
 
In [43]:
#일교차에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['일교차'])
Out[43]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fe2da7f0>
 
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0.0, flags=flags)
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0, flags=flags)
 
In [44]:
#철새도래지거리(m)에 따른 AI 발병 빈도 수
sns.distplot(AI_최종데이터['철새도래지거리'])
Out[44]:
<matplotlib.axes._subplots.AxesSubplot at 0x245fe3c0910>
 
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0.0, flags=flags)
C:\Users\User\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 8722 missing from current font.
  font.set_text(s, 0, flags=flags)
 
In [ ]:
 
반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기