Missing Data Imputation

Medium
pandas

Given a dictionary representing a dataset where values are lists (some entries are None), replace every None with the mean of the non-None values in that column. Return the result as a dict of lists with floats rounded to 2 decimal places.

Example:

Input:  {"A": [1, None, 3], "B": [4, 5, None]}
Output: {"A": [1.0, 2.0, 3.0], "B": [4.0, 5.0, 4.5]}

Test Cases

Python Editor

Output

Click "Run" to see results...