이번에는 결측치를 이용해서 마스크를 만들어보자.
# 참조
import pandas as pd
# 데이터프레임 생성
cols = ['name', 'survived', 'pclass', 'fare', 'sex', 'age']
titanic = pd.read_excel('titanic3.xls', usecols=cols, index_col='name')
titanic

plcass_1_mask = titanic['pclass'] == 1
plcass_2_mask = titanic['pclass'] == 2
titanic[plcass_1_mask | plcass_2_mask]

.isin()으로 동일코드를 구현해보면Series.isin(values)**1 in [1, 2] 2 in [1, 2] 모두 True가 나옴.isin 메소드를 사용하여 각 요소가 특정 값들에 속하는지 여부를 확인할 수 있다.코드
titanic['pclass'].isin([1,2])

pclass 컬럼 중 1또는 2를 구한다.
.****isnull()****titanic에서 Null 데이터를 확인해 보자.
# age열 isnull()
titanic['age'].isnull()

sum() 메서드를 이용해 age에 결측값이 몇개인지 확인해볼 수 있다.
.notnull()**• isnull과 반대로 NA가 아닌 걸 발견하면 True로 반환
age열에서 결측치가 아닌것
titanic['age'].notnull()

나이가 식별되지 않은 사람과 식별된 사람을 찾아보자.
결측치가 있으면 식별이 안된것이니 마스크로 만들어줌.
unknown_age_mask = titanic['age'].isna()
known_age_mask = titanic['age'].notnull()
식별되지 않은사람
# 나이가 식별되지 않은 사람 확인
titanic[unknown_age_mask]

식별된 사람
# 나이가 식별된 사람 확인
titanic[known_age_mask]
