A researcher stores one sample per row, with columns for sample ID, temperature, and collection date. Which description best fits this pandas DataFrame?
2 Working with Data and Data Types Online Quiz Questions
Use this free practice quiz with 20 questions to review 2 Working with Data and Data Types, test your knowledge, and prepare for your next test or exam.
A missing measurement is equivalent to zero even when the dataset does not define it that way. True or false?
- A
True
- B
False
Which pandas function loads a CSV file into a DataFrame?
In a typical tabular dataset, rows represent and columns represent .
A customer ID column contains only digits. Which interpretation is usually most appropriate when deciding how to analyze the column?
- A
Treat the codes as measurements and calculate their average.
- B
Convert the codes to temperatures because both contain digits.
- C
Treat the codes as identifiers rather than quantities.
- D
Treat the codes as dates because they label customer records.
You want to review the distribution of locations while keeping missing entries visible, and also find the missing-value count for each column. Which two pandas expressions are suited to those tasks?
- A
Use
measurements["location"].value_counts(dropna=False)to review location counts while keeping missing values visible. - B
Use
measurements.shapeto count missing values separately in every column. - C
Use
measurements.isna().sum()to count missing values per column. - D
Use
measurements.head()to standardize inconsistent category capitalization automatically.
A numeric-looking column may be imported as if it contains symbols or inconsistent entries.
When importing a CSV, the word “unknown” should be added to na_values only if it represents missing data under that dataset’s conventions.
- A
True
- B
False
What pandas object behaves like a labeled one-dimensional column of a DataFrame?
A date column has been imported as text. What is the most careful next step before converting it to a date-time type?
- A
Convert every value immediately and discard any entry that fails.
- B
Check the format and decide how to handle entries that do not convert.
- C
Assume that every value containing digits is already stored as a number.
- D
Replace all nonnumeric values with zero before checking the column.
A location column appears complete, but some entries may use inconsistent capitalization or spacing. Which two checks are useful for investigating data quality?
- A
Review the column’s distinct values for differences such as
NorthandNORTH. - B
Compare values with the data dictionary, expected units, and plausible ranges.
- C
Rely only on the count of missing values to detect all inconsistent entries.
- D
Automatically change every unusual number without investigating it.
A height column contains some values that are much larger than the others, and you suspect that centimeters and inches may have been mixed. Describe how you would investigate and clean the data without risking valid information.
A dataset uses low, medium, and high to describe rating levels. Which interpretation best accounts for the values’ limited set and their order?
- A
Store the ratings as dates because they have a meaningful sequence.
- B
Treat the ratings as numeric measurements because the categories are ordered.
- C
Treat the ratings as categorical values, recognizing that plain text does not express their order.
- D
Treat the ratings as identifiers because they distinguish one response from another.
A dataset has several labeled columns, and each column contains values for one variable. Which pandas structure best represents the dataset as a whole?
- A
A Series, because it contains multiple labeled columns
- B
A DataFrame, because it is a two-dimensional table with labeled columns
- C
A categorical value, because the table has labels
- D
A Boolean, because each row is one observation
A customer ID column contains only digits. Which approach best reflects what those values mean when choosing how to analyze the column?
- A
Treat it as a quantity and calculate its mean
- B
Treat it as a measurement because it contains digits
- C
Treat it as an identifier rather than a quantity
- D
Treat it as a date because it identifies a customer
A CSV file contains the text “unknown” in a column. Before using na_values=["unknown"] when importing the file, what should you do?
- A
Check whether “unknown” is a missing-value marker in this dataset before passing it to
na_values - B
Always include “unknown” in
na_valuesbecause it is never a meaningful category - C
Convert every text value in the file to a missing value
- D
Use
head()to tell pandas that “unknown” means missing
A date column is imported as text, and some entries may use inconsistent formats. What is the most reliable next step before converting the column to a date-time type?
- A
Convert it immediately and discard any entries that cause errors
- B
Keep it as text permanently because dates cannot be analyzed chronologically
- C
Replace every value that does not look like a date with zero
- D
Check the format and plan how to handle entries that do not convert
In pandas, use isna() or notna() to detect missing values rather than comparing values directly with NaN. True or false?
- A
True
- B
False
Which pandas DataFrame attribute reports the stored data type of each column?
A rating variable uses the limited set of values “low,” “medium,” and “high.” What general data type is suited to representing these group values?