Question
In Python, which method in the Pandas library would you
use to replace NaN values in a DataFrame with the median value of each column?Solution
The fillna() method in Pandas is used to replace NaN values in a DataFrame. By passing df.median() as an argument to fillna(), we can replace missing values with the median value of each column. This approach is especially useful when missing values are suspected to deviate from the mean due to outliers, making median imputation a more robust choice. The Pandas fillna() method is highly flexible and frequently used in data cleaning to handle missing data without discarding rows or losing valuable information in other columns. Option A (df.fillna(df.mean())) is incorrect as it fills NaNs with the mean rather than the median. Option B (df.replace(df.median())) is incorrect because replace() is not used directly for filling NaN values. Option D (df.dropna(inplace=True)) is incorrect as it removes rows with NaNs instead of filling them. Option E (df.interpolate(method="median")) is incorrect as interpolate() does not directly support median filling.
Select the number from among the given options that can replace the question mark (?) in the following series. 543, 518, 495, 474, 455, ?
Which two numbers should be interchanged to make the following equation equal?Â
16 + 8 × 24 ÷ 4 – 26 = 30
In a certain code language,
'time has come' is coded as 'et im ak';
'come with money' is coded as 'nd ak co' andÂ
'money has power...
In a certain code language, '22 55 77' is coded as 'ir pp tt' and '77 66 44' is coded as 'pp kk ll' and '66 11 22' is coded as 'kk tt zz". How is "11" c...
Which answer figure will complete the pattern in the question figure? (rotation is not allowed)
If 'A' stands for '÷ ', 'B' stands for '×', 'C' stands for + and 'D' stands for '–', what will come in place of the question
mark (?) in the ...
A paper is folded at the dotted lines as shown in the first two figures. and cut as shown in the third figure How will it appear when unfolded?
<...
CALANDER is coded in a code as CLANAEDR. Find the code for CIRCULAR under the same rule.
Select the number from among the given options that can replace the question mark (?) in the following series.
3, 17, 73, 297, ? , 4777
...