728x90
ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ถ๋ฌ์ค๊ธฐ
import pandas as pd
import numpy as np
๋ฐ์ดํฐ ๋ก๋ํ๊ธฐ
- ํ๋ค์ค์์ ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ ๋๋ read_csv ์ฌ์ฉ
- ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํด์ df๋ผ๋ ๋ณ์์ ๋ด๊ธฐ
- shape๋ฅผ ํตํด ๋ฐ์ดํฐ์ ๊ฐ์ ์ฐ๊ธฐ, ๊ฒฐ๊ณผ๋ (ํ, ์ด) ์์ผ๋ก ์ถ๋ ฅ๋จ
# read_csv๋ก ๋ถ๋ฌ์จ ํ์ผ์ df๋ผ๋ ๋ณ์์ ๋ด๊ธฐ
df = pd.read_csv("data\์์๊ณต์ธ์์ฅ์งํฅ๊ณต๋จ_์๊ฐ์
์์ ๋ณด_์๋ฃ๊ธฐ๊ด_201909.csv", low_memory=False)
df.shape
๊ฒฐ์ธก์น ํ์ธ
df.isnull()
๊ฒฐ์ธก์น ํฉ๊ณ ๊ตฌํ๊ธฐ
# True๋ 1๋ก
null_count = df.isnull().sum()
null_count
๊ฒฐ์ธก์น ํฉ๊ณ๋ฅผ ๋ง๋๊ทธ๋ํ๋ก ํํํ๊ธฐ
# ์์์ ๊ตฌํ ๊ฒฐ์ธก์น๋ฅผ .plot.barh๋ฅผ ํตํด ๋ง๋๊ทธ๋ํ๋ก ํํ
null_count.plot.barh(figsize=(5, 7))
๊ฒฐ์ธก์น ํฉ๊ณ๋ฅผ ๋ฐ์ดํฐํ๋ ์์ผ๋ก ๋ง๋ค์ด์ฃผ๊ธฐ
# ์์์ ๊ณ์ฐํ ๊ฒฐ์ธก์น ์๋ฅผ reset_index๋ฅผ ํตํด ๋ฐ์ดํฐํ๋ ์์ผ๋ก ๋ง๋ค์ด์ฃผ๊ธฐ
# df_null_count ๋ณ์์ ๊ฒฐ๊ณผ๋ฅผ ๋ด์์ head๋ก ๋ฏธ๋ฆฌ๋ณด๊ธฐ
df_null_count = null_count.reset_index()
df_null_count.head()
'๐ฅ > pandas' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Folium] ์ค์นํ๋ ๋ฒ (0) | 2022.11.04 |
---|---|
[Error] pandas ํ๊ธ ํฐํธ ๊นจ์ง (0) | 2022.11.03 |