## create data
import numpy as np
import pandas as pd
from sklearn.datasets import load_boston
boston = load_boston()
X = pd.DataFrame(
boston.data,
columns=boston.feature_names,
)
X.replace(0, np.NaN, inplace=True)
## count missing values
missing_count=X.apply(
lambda x: (
x.isna().sum()
)
)
## proportion missing values
missing_proportion = X.apply(
lambda x: (
x.isna().mean()
)
)
## create Result DataFrane
result = pd.DataFrame(
dict(
missing_count=missing_count,
missing_proportion=missing_proportion,
)
)
display(result)