import pandas as pd
import seaborn as sns
df = sns.load_dataset('titanic')
df.head(2)
survived | pclass | sex | age | sibsp | parch | fare | embarked | class | who | adult_male | deck | embark_town | alive | alone | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 3 | male | 22.0 | 1 | 0 | 7.2500 | S | Third | man | True | NaN | Southampton | no | False |
1 | 1 | 1 | female | 38.0 | 1 | 0 | 71.2833 | C | First | woman | False | C | Cherbourg | yes | False |
df = df.loc[:, ['age', 'fare']]
df.head()
age | fare | |
---|---|---|
0 | 22.0 | 7.2500 |
1 | 38.0 | 71.2833 |
2 | 26.0 | 7.9250 |
3 | 35.0 | 53.1000 |
4 | 35.0 | 8.0500 |
def missing_value(x: pd.DataFrame) -> pd.DataFrame:
return x.isnull()
result_df = df.pipe(missing_value)
result_df.head()
age | fare | |
---|---|---|
0 | False | False |
1 | False | False |
2 | False | False |
3 | False | False |
4 | False | False |
def missing_count(x: pd.DataFrame) -> pd.Series:
return x.isnull().sum()
result_series = df.pipe(missing_count)
result_series
age 177 fare 0 dtype: int64
def total_number_missing(x: pd.DataFrame) -> int:
return x.isnull().sum().sum()
result_value = df.pipe(total_number_missing)
result_value
177