Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 3 : df['age'].fillna(df['age'].mean())

Advertisement

Detailed Solution

सही उत्तर df['age'].fillna(df['age'].mean()) है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Which code correctly fills missing values in the 'age' column with that column's mean? / 'age' कॉलम के लापता मानों को उसी कॉलम के औसत से भरने वाला सही कोड कौन-सा है?

1.
df.dropna(subset=['age'])
2.
df['age'].fillna(0)
3.
df['age'].fillna(df['age'].mean())
4.
df['age'].replace('NaN', df['age'].mean())

Correct Answer: df['age'].fillna(df['age'].mean())

fillna() replaces missing values with the supplied value, and df['age'].mean() computes that column's mean. dropna() removes rows instead of filling them. / fillna() लापता मानों को दिए गए मान से भरता है, और df['age'].mean() उसी कॉलम का औसत निकालता है। dropna() भरने के बजाय पंक्तियाँ हटाता है।

Downloaded from PrepSnap (prepsnap.in)