Replace Missing Values with Most Frequent number under Condition
This solution works well but I don't know why above don't work!
Imputer = SimpleImputer(missing_values=np.nan, strategy='most_frequent')
for i in range(2):
    for j in range(1,4):
        ls = np.array(df.Age[((df.Sex==i) &amp; (df.Pclass==j))]).reshape(-1,1)
        df.Age[((df.Sex==i) &amp; (df.Pclass==j))] = Imputer.fit_transform(ls)[:,0]
df.Age.isnull().sum()