๋ฐ์ํ
def cnt_nan(df):
"""์ ์ฒด ํ NaN ๊ฐฏ์ ์กฐํ
:param pandas.DataFrame df: dataframe
:return: dataframe
Example:
๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ์ธ์:
>>> cnt_nan(df)
"""
df_len = len(df)
df = pd.DataFrame(df.isnull().sum())
df['%'] = (df[0]/df_len)*100 # ๋น์จ
df = df.rename(columns = {0: 'NaN cnt'})
return df
๋ฐ์ํ
'Python > Pandas' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] Dataframe - iterrows (0) | 2020.08.21 |
---|---|
[Python] Pandas - Dataframe, NaN ๊ฐ ์ฒ๋ฆฌ (0) | 2020.08.12 |
[Python] Pandas - Dataframe, json ์ผ๋ก ๋ณ๊ฒฝ (0) | 2020.07.29 |
[Python] Pandas - Dataframe ์ ์ฒด ํ, ์ด ๋ณด๊ธฐ ์ค์ (0) | 2020.06.02 |
[Python] Pandas - dataframe์ ํน์ ๊ฐ์ NaN์ผ๋ก ๋ณ๊ฒฝ (0) | 2020.06.02 |