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.
Palash invest thrice the sum invested by Vicky and withdraws half of the sum after 2 months and again withdraws half of the remaining sum after 3 months...
In a joint business venture, 'A' contributes Rs. 2400, which is 25% less than 'B’s investment. While 'A's investment lasts for 8 months, 'B' only inve...
A invested Rs. X in a scheme. After 6 months, B joined with Rs 4000 more than that of A. After an year, ratio of profit of B to the total profit was 3: ...
A starts business with Rs.6000 and after 9 months, B joins with A as his partner. After a year, the profit divided in the 3:5. What is B’s contributi...
'A' and 'B' started a business by investing Rs. 6,000 and Rs. 7,000, respectively. 1 year later, 'A' and 'B' increased their investments by 60% and Rs. ...
P started a business investing Rs.12000. After 3 months, Q joined her with the capital of Rs.18000. After another 6 months, R joined them with the capit...
A and B started a business with investments in the ratio of 6:7 respectively. If after one year, the profit earned by A is Rs. 3000, then find the total...
'Pawan' and 'Qureshi' initiated a business venture with investments in the ratio of 2:3, respectively. After 8 months, 'Rita' became a partner in the bu...
A and B started a business with investments in the ratio 3:5 respectively. After 5 months, C joined them with an investment 60% more than the investment...
P and Q together started a business with initial investment in the ratio of 1:3, respectively. The time-period of investment for P and Q is in the ratio...