Which Python expression selects rows in df_customers where any column contains NULL values (axis=1)?

Prepare for the DP-600 Fabric Analytics Engineer Exam. Study with flashcards and multiple choice questions, each offering hints and detailed explanations. Enhance your chances of success on the exam!

Multiple Choice

Which Python expression selects rows in df_customers where any column contains NULL values (axis=1)?

Explanation:
To find rows that have any missing values, create a boolean mask across cells with isnull(), then reduce along columns in each row with any(axis=1). df_customers.isnull() marks True where a cell is NULL. any(axis=1) looks at all columns in each row and returns True if any of those cells are True (i.e., if the row contains at least one NULL). This boolean Series can be used to index the DataFrame to select exactly the rows that have at least one missing value. The other options don’t fit: isnull().all(axis=1) would require every column in a row to be NULL; dropna() removes rows with any NULLs rather than selecting them; isnull().sum(axis=1) returns a numeric count of NULLs per row, not a boolean mask for selection.

To find rows that have any missing values, create a boolean mask across cells with isnull(), then reduce along columns in each row with any(axis=1). df_customers.isnull() marks True where a cell is NULL. any(axis=1) looks at all columns in each row and returns True if any of those cells are True (i.e., if the row contains at least one NULL). This boolean Series can be used to index the DataFrame to select exactly the rows that have at least one missing value.

The other options don’t fit: isnull().all(axis=1) would require every column in a row to be NULL; dropna() removes rows with any NULLs rather than selecting them; isnull().sum(axis=1) returns a numeric count of NULLs per row, not a boolean mask for selection.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy