exam questions

Exam DP-100 All Questions

View all questions & answers for the DP-100 exam

Exam DP-100 topic 3 question 136 discussion

Actual exam question from Microsoft's DP-100
Question #: 136
Topic #: 3
[All DP-100 Questions]

HOTSPOT -

You load data from a notebook in an Azure Machine Learning workspace into a pandas dataframe. The data contains 10,000 records. Each record consists of 10 columns.

You must identify the number of missing values in each of the columns.

You need to complete the Python code that will return the number of missing values in each of the columns.

Which code segments should you use? To answer, select the appropriate options in the answer area.

NOTE: Each correct selection is worth one point.

Show Suggested Answer Hide Answer
Suggested Answer:

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
avotofu
Highly Voted 1 year, 7 months ago
Answer is df.shape[0] - df.count() df.shape[0] = total number of rows. df.count() = non-missing values
upvoted 18 times
...
Lion007
Most Recent 11 months, 1 week ago
WRONG. The Correct answer is: shape and 0 The shape attribute of a DataFrame returns the dimensionality of the DataFrame, where shape[0] returns the number of Rows and shape[1] returns the number of Columns. If you have 10,000 rows ( df.shape[0] equals 10,000 ) and you want to find out how many values are missing in each Column, you would use df.shape[0] and subtract the number of non-missing values per column from the total number of rows to get the number of missing values like this: missing_values_per_column = df.shape[0] - df.count() The df.count() method returns the number of non-NA/non-missing values in each column. By subtracting this from the total number of rows (df.shape[0]), you get the count of missing values per column.
upvoted 4 times
...
BR_CS
1 year, 3 months ago
A pretty silly approach, but df.shape[0] would be correct to get the #of total rows.
upvoted 1 times
...
snegnik
1 year, 6 months ago
strange examples. I use this approach # Assuming you have loaded the data into a pandas DataFrame named 'df' missing_values_count = df.isnull().sum() # Output the number of missing values in each column print(missing_values_count)
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...