Dataset Completeness Overview Series: Missing Cells, Complete Rows and Empty Columns in Pandas

Quick Overview

Write a pandas function that summarizes how complete a DataFrame is as a fixed nine-entry float64 Series: row, column and cell counts, missing-cell and complete-row percentages, and how many columns are partly or fully empty. It tests boolean masks, axis-wise reductions and matching an exact output contract.

Dataset Completeness Overview Series: Missing Cells, Complete Rows and Empty Columns in Pandas

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

Write `completeness_overview(df)` for a pandas DataFrame. It returns a `float64` Series named `'completeness_overview'` with exactly this index, in this order: ```python ['n_rows', 'n_cols', 'n_cells', 'n_missing_cells', 'pct_missing_cells', 'n_complete_rows', 'pct_complete_rows', 'n_cols_any_missing', 'n_cols_all_missing'] ``` The entries are defined as follows: - `n_cells` = `n_rows * n_cols`, `n_missing_cells` = total NA cells, `pct_missing_cells` = `n_missing_cells / n_cells * 100`. - `n_complete_rows` = rows with zero NA cells, `pct_complete_rows` = `n_complete_rows / n_rows * 100`. - `n_cols_any_missing` = columns with at least one NA, `n_cols_all_missing` = columns entirely NA. ```hint One mask All nine numbers can come from a single boolean missingness mask. For each one, decide whether it reduces over cells, rows or columns. ``` ### Constraints & Assumptions - Every entry, counts included, is `float64`. Percentages are on a 0-100 scale. - Do not modify `df`. - The grader uses a fixed frame (one all-null column, one fully populated column, several partially null columns) and compares with `assert_series_equal`, so the index order, the Series name and the dtype all have to match. ### What a Strong Answer Covers - Deriving every metric from one missingness mask, with each count reduced over the right axis. - Keeping cell-level missingness and row-level completeness apart: a row is complete only when none of its cells is NA. - Returning the exact index order, the name `completeness_overview` and `float64` for every entry, so `assert_series_equal` passes. - Leaving the input frame unchanged. ### Follow-up Questions - How would you handle an empty frame (`n_rows == 0`) without a division-by-zero error? - How would you extend this to a per-column completeness report? - Which values does `isna()` treat as missing, and how would you also count placeholders such as empty strings or `-999`?

Overview: Write a pandas function that summarizes how complete a DataFrame is as a fixed nine-entry float64 Series: row, column and cell counts, missing-cell and complete-row percentages, and how many columns are partly or fully empty. It tests boolean masks, axis-wise reductions and matching an exact output contract.

Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

Write completeness_overview(df) for a pandas DataFrame. It returns a float64 Series named 'completeness_overview' with exactly this index, in this order:

['n_rows', 'n_cols', 'n_cells', 'n_missing_cells', 'pct_missing_cells',
 'n_complete_rows', 'pct_complete_rows', 'n_cols_any_missing', 'n_cols_all_missing']

The entries are defined as follows:

  • n_cells = n_rows * n_cols , n_missing_cells = total NA cells, pct_missing_cells = n_missing_cells / n_cells * 100 .
  • n_complete_rows = rows with zero NA cells, pct_complete_rows = n_complete_rows / n_rows * 100 .
  • n_cols_any_missing = columns with at least one NA, n_cols_all_missing = columns entirely NA.

Constraints & Assumptions

  • Every entry, counts included, is float64 . Percentages are on a 0-100 scale.
  • Do not modify df .
  • The grader uses a fixed frame (one all-null column, one fully populated column, several partially null columns) and compares with assert_series_equal , so the index order, the Series name and the dtype all have to match.

What a Strong Answer Covers Guidance

  • Deriving every metric from one missingness mask, with each count reduced over the right axis.
  • Keeping cell-level missingness and row-level completeness apart: a row is complete only when none of its cells is NA.
  • Returning the exact index order, the name completeness_overview and float64 for every entry, so assert_series_equal passes.
  • Leaving the input frame unchanged.

Follow-up Questions Guidance

  • How would you handle an empty frame ( n_rows == 0 ) without a division-by-zero error?
  • How would you extend this to a per-column completeness report?
  • Which values does isna() treat as missing, and how would you also count placeholders such as empty strings or -999 ?