Fill missing values with means

Quick Overview

This question evaluates proficiency in missing-data imputation and pandas DataFrame manipulation, testing skills in column-wise aggregation, group-wise operations, and edge-case handling within the Data Manipulation (SQL/Python) domain.

Fill missing values with means

Company: Aeonea

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Technical Screen

You are given a pandas DataFrame df with missing values in multiple numeric columns. Write a concise pandas expression to replace NaNs in each numeric column with that column's mean while leaving non-numeric columns unchanged. Also explain how you would: (a) perform the operation in-place, (b) compute and apply per-group means based on a key column (e.g., 'group'), and (c) skip columns whose values are all NaN.

Quick Answer: This question evaluates proficiency in missing-data imputation and pandas DataFrame manipulation, testing skills in column-wise aggregation, group-wise operations, and edge-case handling within the Data Manipulation (SQL/Python) domain.

|Home/Data Manipulation (SQL/Python)/Aeonea
Aeonea logo
Aeonea
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenData Manipulation (SQL/Python)
6
0

You are given a pandas DataFrame df with missing values in multiple numeric columns. Write a concise pandas expression to replace NaNs in each numeric column with that column's mean while leaving non-numeric columns unchanged. Also explain how you would: (a) perform the operation in-place, (b) compute and apply per-group means based on a key column (e.g., 'group'), and (c) skip columns whose values are all NaN.

Loading comments...