Pandas 결측치 특정값으로 채우기

1 개요[ | ]

Pandas 결측치 특정 값으로 채우기
from io import StringIO
import pandas as pd
csv = """
Class  Name English Math
    A Alice      90   60
    A   Bob      80   NA
    A Carol      NA   80
    B  Dave      NA   90
    B Erwin      60   80
"""
df = pd.read_csv(StringIO(csv),sep='\s+')
df
# 모든 컬럼의 결측치를 0으로 채우기
df.fillna(0)
# 모든 컬럼의 결측치를 missing으로 채우기
df.fillna("missing")
# 특정 컬럼의 결측치를 0으로 채우기
df["English"].fillna(0)
# 특정 컬럼의 결측치를 missing으로 채우기
df["Math"].fillna("missing")

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}