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.
Which year did SEBI make BRSR mandatory for the top 1,000 listed entities by market capitalization?
The cost incurred for an additional product is known as ________
________ is the process of bringing together physical, financial and human resources and developing productive relationship amongst them for achievement...
W hat is the maximum permissible bank finance (MPBF) that a bank may lend , a ccording to the Tandon Committee's recommendations ?
A company fails to accrue wages for March that will be paid in April. The company’s year-end balance sheet liabilities:
The project is requiring an investment of 40000 and is depreciated on a SLM basis and the Cash Inflows of the project are the following, what is the ARR...
Alderfer suggested that a person can be motivated by fulling three types of needs – Existence, relatedness and Growth (ERG). Which of the following i...
Which of the following derivative instrument is a type of financial derivative in which fixed payments of interest are exchanged by two counterparties f...
Loan in the repo market involves a very little credit risk because ________
Which of the following ratios are used to measure a firm’s liquidity and solvency?