
import pandas as pd
def dropMissingData(students: pd.DataFrame) -> pd.DataFrame:
return students.loc[~students['name'].isnull()]
# 별 난리를 다 쳐도 해내지 못함 ;;
#print(drop.students['name'] == None)
#print(students.drop(students['name'] == None))
#return students[students['name'].dropna(axis=0)]
#print(students['name'].isnull())
loc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
df.loc[조건에 따른 true false 결과 series]
조건에 맞춰서 아래와 같은 Series를 얻어내고,(위 코드에서는 .isnull 로 얻음)
0 False
1 True
2 False
3 False
Name: name, dtype: bool
얘를 df.loc[] 안에 넣어주면 된다!!!!!!!!!!!!!!!!!!!!!!!!!!고.
그럼 True인 행만 반환한다.
df.dropna(subset=['칼럼명'])
이걸 몰라서 바로 못풀었네
df.dropna() 또는 df.dropna(axis=0)로 하면, 결측치가 있는 행 제거된다.
df.dropna(axis=1) 하면, 결측치가 있는 칼럼 제거된다.
조건은 subset=['칼럼명'] 으로 준다.
df.isnull()
df['칼럼명'].isnull()
이런식으로 출력됨. (Series)
0 False
1 True
2 False
3 False
Name: name, dtype: bool