Write Python code to read a CSV and impute null values with median
Asked in the Technical Round stage. Coding portion.
Implement impute_csv(csv_text). The input is a CSV string with a header row. A null is an empty cell or the case-insensitive value null. For each column containing only numeric non-null values, replace nulls with that column's median. Leave nonnumeric columns, all-null columns, and existing values unchanged. Return the resulting CSV string with the same header and row order. For an even number of values, use the arithmetic mean of the two middle values. Median replacements should be represented as decimal text.
null value.def impute_csv(csv_text):