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 financial assistance scheme of APEDA for exporters is known as:
What type of food businesses need a State License under FSSAI?
Which of these is NOT allowed under organic livestock farming?
A system in which forest trees are grown along with agricultural crops and grasses on the same land at the same time is known as ____
Under FSSAI, which license is applicable for food businesses operating in multiple states or involved in exports/imports?
Which scheme is launched by APEDA to promote export of agri-products from clusters identified across India?
What does PGS stand for in organic certification?
Which of the following substances is prohibited under NSOP guidelines?
Under which Act was APEDA established to promote the export of agricultural and processed food products?
Which international body develops standards for food safety referred to in SPS?