Pandas 특정컬럼이 결측치인 행 제거

1 개요[ | ]

Pandas 특정컬럼이 결측치인 행 제거

2 예시 1[ | ]

import numpy as np
import pandas as pd

df = pd.DataFrame({"name": ['Alfred', 'Batman', 'Catwoman'],
                   "toy": [np.nan, 'Batmobile', 'Bullwhip'],
                   "born": [pd.NaT, pd.Timestamp("1940-04-25"), pd.NaT]})
df
df.dropna(subset=['toy'])

3 예시 2[ | ]

import pandas as pd

df = pd.DataFrame(columns =
  ['Class','Name' ,'English','Math'], data = [
  ['A'    ,'Alice', 90      , 60   ],
  ['A'    ,'Bob'  , 80      , None ],
  ['B'    ,'Carol', None    , 80   ],
  ['B'    ,'Dave' , 60      , 80   ],
  ])
df
df.dropna(subset=['Math'])

4 같이 보기[ | ]

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