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?
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.
Under Pradhan Mantri Gram Sadak Yojana, Union Government bears ____% of the project cost in respect of projects sanctioned in North-Eastern and Himalaya...
India's company HealthKart’s MuscleBlaze signs whom as brand ambassador?
Who unveiled the mascot 'Juhi' for the Jharkhand Women’s Asian Champions Trophy Ranchi 2023, and what is the inspiration behind the mascot?
The 40th edition of "Hunar Haat", a platform to preserve, protect and promote local artisans and craftsmen, was inaugurated by the Union minister Anurag...
Recently the central government launches 3 schemes to strengthen MSMEs in pharmaceutical sector, who will be the project management consultant for impl...
How much of India’s total gold reserve is now held domestically, as per RBI’s recent data?
Badri Narayan received the prestigious literary award Sahitya Akademi Award, 2022 for ?
Consider the following statements:
I. India's first-ever National Air Sports Policy-2022 has been launched by Sports Authority of India.
<...Deanna Syme Tewari, who passed away recently, was known for her achievements in which field?
RBI has extended the deadline for non-banking financial companies (NBFCs) to comply with new Non-Performing Assets (NPAs) classification norms to Septem...