← All Python interview questions

Produce a data-quality audit for a raw extract

HardPandas — CleaningAccentureEY

Before any analysis, you run a standard audit on a raw extract.

Write audit(df) that returns a dict with rows, duplicate_rows, null_counts (a dict of column to null count, only for columns that actually have nulls), constant_columns (a sorted list of columns with a single distinct non-null value) and negative_amounts (the count of rows where amount is below zero).