Start by writing the concise expression using `df.fillna(df.mean(numeric_only=True))` to fill NaNs in numeric columns with their means. Then explain the in-place variant with `inplace=True` or reassignment, and discuss per-group means using `groupby` and `transform`, and skipping all-NaN columns by filtering them out.
Pro tip: Mention that `df.mean(numeric_only=True)` automatically excludes non-numeric columns, and that using `transform` for group-wise filling preserves the original index alignment. Also note that all-NaN columns are skipped by default because their mean is NaN, but you can explicitly drop them to avoid warnings.
Write `df.fillna(df.mean(numeric_only=True))` to fill NaNs in each numeric column with that column's mean, leaving non-numeric columns untouched.
Explain that you can use `df.fillna(df.mean(numeric_only=True), inplace=True)` or reassign `df = df.fillna(...)` to modify the DataFrame in place.
Describe using `df.groupby('key').transform(lambda x: x.fillna(x.mean()))` to fill NaNs with group-specific means, ensuring alignment with the original DataFrame.
Mention that columns with all NaNs are automatically skipped because their mean is NaN, but you can explicitly drop them with `df.dropna(axis=1, how='all')` before imputation.
Emphasize that `numeric_only=True` ensures only numeric columns are considered, so non-numeric columns remain unchanged.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.