πŸ’Ώ Data/이λͺ¨μ €λͺ¨

데이터 정리 및 μ‹œκ°ν™” μ˜ˆμ‹œ 기둝

Jayden1116 2021. 12. 10. 00:19
from google.colab import files
uploaded = files.upload()
import pandas as pd # μ—…λ‘œλ“œν•˜λŠ” λ°©μ‹μœΌλ‘œ μ§„ν–‰ν•˜μ˜€μŠ΅λ‹ˆλ‹€.
file1 = pd.read_csv('n113_λ§ˆλ¦¬ν™”λ‚˜.txt', sep='\t')
file2 = pd.read_csv('n113_ν•΄μš΄.txt', sep='\t') # txt 데이터라 κ΅¬λΆ„μžλ₯Ό μ •ν•΄μ£Όμ—ˆμŠ΅λ‹ˆλ‹€.

데이터 μ „μ²˜λ¦¬ κ³Όμ • μ½”λ“œλŠ” μƒλž΅ν•˜κ³˜μŠ΅λ‹ˆλ‹€.

image

μœ„μ™€ 같이 데이터λ₯Ό μ •λ¦¬ν•œ ν›„ 'ν…Œλ§ˆ'둜 각 컬럼의 평균 ν…Œμ΄λΈ”μ„ λ§Œλ“€μ—ˆμŠ΅λ‹ˆλ‹€.

df1 = df.groupby('ν…Œλ§ˆ').mean()

image

!sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf

import matplotlib.pyplot as plt
plt.rc('font', family='NanumBarunGothic') # ν•œκΈ€ 폰트 깨지지 μ•Šκ²Œ ν•΄μ£ΌλŠ” μž‘μ—…μž…λ‹ˆλ‹€!(λ„ˆλ¬΄ μ†Œμ€‘)
import matplotlib.pyplot as plt
import seaborn as sns

plt.figure(figsize=(20,5))
ax1 = plt.subplot(1, 3, 1)
ax2 = plt.subplot(1, 3, 2)
ax3 = plt.subplot(1, 3, 3)

sns.barplot(x=df1.index, y='λ§€μΆœμ•‘', data=df1, ax=ax1)
sns.barplot(x=df1.index, y='μžμ‚°μ΄κ³„', data=df1, ax=ax2)
sns.barplot(x=df1.index, y='μ£Όλ‹Ήμˆœμ΄μ΅', data=df1, ax=ax3)

plt.show()

image