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.
The facility of national portability of ration card is named as____
The licensing authority for the manufacture of mineral water and packaged drinking water in India is:
____ was marked as the International Year of soils.
The Central Rice Research Institute (CRRI) in India has been pivotal in rice research and development. Where is it headquartered?
_____is the hardiest crop among all the pulses.
Stocking of fishes of different habits, in same pond is known as:
In murrah Buffalo what is the age at first calving
In which of the following country The World First Station for seed testing was established
The maximum amount of energy is liberated on oxidation of ____
Which of the following common names of wheat is incorrectly matched with its scientific name?