Unit 10: Data cleanup - Practice Quiz

ECAP776 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which pandas method displays the first few rows of a DataFrame?

Investigation Easy
A. df.head()
B. df.describe()
C. df.tail()
D. df.info()

2 Which DataFrame attribute returns the number of rows and columns?

Investigation Easy
A. df.size
B. df.columns
C. df.shape
D. df.index

3 Which pandas expression counts missing values in each column?

Investigation Easy
A. df.describe() followed by manually counting every blank cell
B. df.isna().sum()
C. df.fillna().sum()
D. df.dropna().sum()

4 Which method identifies duplicate rows in a pandas DataFrame?

Investigation Easy
A. df.duplicated()
B. df.unique()
C. df.repeated()
D. df.dropna()

5 What does df.info() mainly show?

Investigation Easy
A. Only the first five records
B. Column types and non-null counts
C. A complete statistical analysis of every possible relationship
D. Only duplicated row values

6 Which method returns the distinct values in a pandas Series named colors?

Investigation Easy
A. colors.value()
B. colors.describe()
C. colors.unique()
D. colors.duplicated()

7 Which method provides summary statistics such as count, mean, and standard deviation for numeric columns?

Investigation Easy
A. df.head()
B. df.info()
C. df.describe()
D. df.columns()

8 Which operator checks whether two Python values are equal?

Matching Easy
A. !=
B. >=
C. =
D. ==

9 Which pandas method checks whether Series values appear in a given list?

Matching Easy
A. astype()
B. isna()
C. isin()
D. sort_values()

10 Which expression finds rows where the city column contains the text York?

Matching Easy
A. df['city'].str.contains('York')
B. df['city'].apply() with a separate database lookup for each row
C. df['city'].str.replace('York')
D. df['city'].str.len('York')

11 In a regular expression, what does \d match?

Matching Easy
A. A space
B. A letter
C. A punctuation mark
D. A digit

12 Why might text be converted to lowercase before matching?

Matching Easy
A. To reduce case differences
B. To sort rows automatically
C. To translate every value into a different natural language
D. To remove all digits

13 Which pandas function combines two DataFrames by matching values in a shared key column?

Matching Easy
A. pd.read_csv()
B. pd.to_datetime()
C. pd.merge()
D. pd.concat()

14 What is an exact match?

Matching Easy
A. Two values that are identical
B. Two values with similar lengths
C. Two values in nearby rows
D. Two values that become related after several unrelated columns are deleted

15 Which string method removes leading and trailing whitespace?

Formatting Easy
A. replace()
B. find()
C. strip()
D. split()

16 Which string method changes data cleanup to Data Cleanup?

Formatting Easy
A. upper()
B. capitalize()
C. title()
D. lower()

17 Which function converts a pandas column to datetime values?

Formatting Easy
A. pd.format_dates_and_rebuild_the_entire_dataframe()
B. pd.read_html()
C. pd.to_numeric()
D. pd.to_datetime()

18 What does round(3.14159, 2) return?

Formatting Easy
A. 3.142
B. 3.1
C. 4.00
D. 3.14

19 Which pandas method can rename DataFrame columns?

Formatting Easy
A. replace()
B. reindex()
C. rename()
D. reset_index()

20 Which Python feature inserts a variable directly into a formatted string?

Formatting Easy
A. A Boolean mask
B. An f-string
C. A list slice
D. A loop that manually joins every character and converts each value separately

21 A pandas DataFrame df contains missing values represented by both None and NaN. Which expression returns the number of missing values in each column?

Investigation Medium
A. df.isnull().any()
B. df.count().sum()
C. df.isna().count()
D. df.isna().sum()

22 A column named age was imported with the object data type. Which command is most useful for examining the Python types of its individual values?

Investigation Medium
A. df["age"].describe(include="all")
B. df["age"].astype(str).count()
C. df["age"].map(type).value_counts()
D. df["age"].dtype.value_counts()

23 Which pandas expression identifies every row that belongs to a duplicated customer_id group, including the first occurrence?

Investigation Medium
A. df.duplicated("customer_id", keep=False)
B. df.drop_duplicates("customer_id").index
C. df.duplicated("customer_id", keep="first")
D. df["customer_id"].is_unique

24 The values in df["status"] should be Open, Closed, or Pending. Which expression most directly reveals unexpected spellings and their frequencies?

Investigation Medium
A. df["status"].value_counts(dropna=False)
B. df["status"].sort_values(ignore_index=True)
C. df["status"].describe().loc["count"]
D. df["status"].nunique(dropna=False)

25 For the sorted values [10, 12, 13, 15, 16, 18, 40], suppose , , and the IQR rule uses . Which value is flagged as an upper outlier?

Investigation Medium
A. 27
B. 13
C. 18
D. 40

26 A DataFrame has 1,000 rows, but df["email"].count() returns 940. What does this establish?

Investigation Medium
A. The column has 940 unique entries
B. The column has 60 duplicate entries
C. The column has 940 valid formats
D. The column has 60 missing entries

27 Which call best summarizes numerical columns with count, mean, standard deviation, quartiles, minimum, and maximum?

Investigation Medium
A. df.describe()
B. df.value_counts()
C. df.info()
D. df.memory_usage()

28 Which regular expression matches a string containing exactly five digits and no other characters?

Matching Medium
A. r"^\d{5}$"
B. r"\d{1,5}$"
C. r"\d{5,}"
D. r"^\d+$"

29 Given text = "Order ID: AB-2048 completed", which function call returns the first substring matching the pattern r"[A-Z]{2}-\d{4}"?

Matching Medium
A. re.fullmatch(pattern, text).group()
B. re.match(pattern, text).group()
C. re.search(pattern, text).group()
D. re.split(pattern, text)[0]

30 Two name columns contain " Alice Smith " and "alice smith". Which normalization makes these values equal without changing their word order?

Matching Medium
A. Apply str.title().str.swapcase()
B. Apply str.split().str.reverse()
C. Apply str.strip().str.casefold()
D. Apply str.upper().str.rstrip("h")

31 A left table contains customer records, while a lookup table maps each customer_id to a region. Which merge keeps every customer even when no region matches?

Matching Medium
A. customers.merge(regions, on="customer_id", how="cross")
B. customers.merge(regions, on="customer_id", how="left")
C. customers.merge(regions, on="customer_id", how="inner")
D. customers.merge(regions, on="customer_id", how="right")

32 A lookup table unexpectedly has two rows for the same product_id. What can happen when it is merged with a sales table on product_id?

Matching Medium
A. Unmatched sales rows become duplicated
B. The merge automatically averages matches
C. Matching sales rows can be duplicated
D. Duplicate lookup rows are ignored

33 Which expression selects rows whose code value starts with two uppercase letters followed by exactly three digits?

Matching Medium
A. df["code"].str.match(r"\d{3}[A-Z]{2}")
B. df["code"].str.contains(r"[A-Z]\d{3}")
C. df["code"].str.startswith(r"[A-Z]{2}")
D. df["code"].str.fullmatch(r"[A-Z]{2}\d{3}")

34 You need to find approximate duplicates such as "Jon Smyth" and "John Smith". Which technique is most appropriate after basic text normalization?

Matching Medium
A. Convert strings directly to floating-point values
B. Compare strings using exact equality only
C. Compare strings using edit-distance similarity
D. Sort strings by their original row indexes

35 A column contains dates such as "31/12/2025". Which conversion explicitly interprets them as day/month/year?

Formatting Medium
A. pd.to_numeric(df["date"], errors="coerce")
B. pd.to_datetime(df["date"], format="%m/%d/%Y")
C. df["date"].astype("datetime", format="%Y/%m/%d")
D. pd.to_datetime(df["date"], format="%d/%m/%Y")

36 A price column contains values such as "$1,250.50". Which operation correctly prepares the strings for conversion with astype(float)?

Formatting Medium
A. Replace , with . only
B. Remove both $ and , characters
C. Remove both . and , characters
D. Replace $ with . only

37 Which f-string formats value = 0.375 as the string "37.5%"?

Formatting Medium
A. f"{value * 10:.1%}"
B. f"{value:.1%}"
C. f"{value:%1.1f}"
D. f"{value:.1f}%"

38 A phone column should contain digits only, but values include spaces, parentheses, and hyphens. Which pandas expression removes every non-digit character?

Formatting Medium
A. df["phone"].str.strip("()-")
B. df["phone"].str.replace(r"\d", "", regex=True)
C. df["phone"].str.replace(r"\D", "", regex=True)
D. df["phone"].str.extract(r"\D+")

39 Which expression converts the integer 42 into the zero-padded string "00042"?

Formatting Medium
A. f"{42:5d}"
B. f"{42:05f}"
C. f"{42:05d}"
D. f"{42:.5d}"

40 A text column contains inconsistent internal whitespace, such as "New York" and "New York". Which expression standardizes every run of whitespace to one space and removes edge whitespace?

Formatting Medium
A. df["city"].str.replace(" ", "", regex=False).str.strip()
B. df["city"].str.replace(r"\s+", " ", regex=True).str.strip()
C. df["city"].str.pad(8, fillchar=" ").str.rstrip()
D. df["city"].str.split(" ").str.get(0).str.strip()

41 Given s = pd.Series([" NA ", "", None, "n/a", "0", " NaN "]), what does clean.isna().sum() return after clean = s.astype("string").str.strip().str.casefold().replace({"": pd.NA, "na": pd.NA, "n/a": pd.NA, "nan": pd.NA})?

Investigation Hard
A. 4
B. 5
C. 3
D. 6

42 A series contains s = pd.Series([" José ", "JOSE\u0301", "Jose", "josé "]). After applying Unicode NFC normalization, trimming, and casefold(), how many rows are marked by duplicated(keep=False)?

Investigation Hard
A. 2
B. 3
C. 1
D. 4

43 For s = pd.Series(["1", "2.0", "1e3", "NaN", "∞", "-"]), let n = pd.to_numeric(s, errors="coerce"). How many elements satisfy np.isfinite(n)?

Investigation Hard
A. 4
B. 5
C. 2
D. 3

44 Using pandas' default linear quantile interpolation, which values are outliers under the rule or for the data [10, 10, 10, 100]?

Investigation Hard
A. Only 10
B. Both values
C. Only 100
D. No values

45 A DataFrame has rows (A, 1), (A, NaN), (A, NaN), and (B, NaN) in columns group and value. What is the sum of df.duplicated(["group", "value"], keep=False)?

Investigation Hard
A. 3
B. 0
C. 1
D. 2

46 Which expression most accurately counts user-perceived characters in text containing combining marks and multi-code-point emoji?

Investigation Hard
A. len(unicodedata.normalize("NFC", s))
B. len(s.encode("utf-16")) // 2
C. len(regex.findall(r"\X", s))
D. len(s.encode("utf-8"))

47 What is the row count of left.merge(right, on="k", how="inner") when left["k"] = [1.0, np.nan, np.nan] and right["k"] = [np.nan, 1.0]?

Matching Hard
A. 4 rows
B. 3 rows
C. 2 rows
D. 1 row

48 What happens when merging left keys [1, 2, 2] with right keys [1, 2, 2] using pd.merge(..., validate="many_to_one")?

Matching Hard
A. It raises pandas.errors.MergeError
B. It drops duplicated right keys
C. It returns three matched rows
D. It returns five matched rows

49 Which normalization correctly makes German "Straße" match "STRASSE" for caseless identifier comparison?

Matching Hard
A. Apply lower() to both strings
B. Apply swapcase() to both strings
C. Apply casefold() to both strings
D. Apply capitalize() to both strings

50 To accept only complete identifiers such as AB-123 under the pattern [A-Z]{2}-\d{3}, which pandas expression is the safest?

Matching Hard
A. s.str.contains(pattern, na=False)
B. s.str.fullmatch(pattern, na=False)
C. s.str.match(pattern, na=False)
D. s.str.findall(pattern).str.len() > 0

51 Three source records must match three master records one-to-one using a matrix of pairwise edit costs. Which method minimizes the total cost without assigning a master record twice?

Matching Hard
A. Thresholded connected-component clustering
B. Linear-sum assignment optimization
C. Stable sorting by source identifier
D. Independent row-wise minimum selection

52 Records and have similarity , and have similarity , and and have similarity . What risk arises if thresholded matches at are clustered using connected components?

Matching Hard
A. A normalization collision removes record B
B. A blocking rule separates A from B
C. A chaining effect groups A with C
D. A tie-breaking rule discards record C

53 A matcher declares two records equal when normalized email or normalized phone agrees. Which rule best prevents two absent values from creating a false match?

Matching Hard
A. Replace every absent value with an empty string
B. Convert every absent value to a shared sentinel
C. Compare fields only when both values are nonmissing
D. Treat absent values as exact wildcard matches

54 How many distinct normalized values remain from ["ABC", "ABC", "abc", "Abc"] after applying Unicode NFKC normalization followed by casefold()?

Matching Hard
A. 1
B. 4
C. 2
D. 3

55 What is produced by [Decimal(x).quantize(Decimal("0.01"), rounding=ROUND_HALF_EVEN) for x in ["2.345", "2.355"]]?

Formatting Hard
A. [Decimal("2.35"), Decimal("2.35")]
B. [Decimal("2.34"), Decimal("2.36")]
C. [Decimal("2.35"), Decimal("2.36")]
D. [Decimal("2.34"), Decimal("2.35")]

56 Naive timestamps 2024-11-03 01:30 and 2024-03-10 02:30 are localized to America/New_York with ambiguous="NaT" and nonexistent="shift_forward". Which result is correct?

Formatting Hard
A. The first is NaT and the second becomes 03:00
B. The first becomes 01:00 and the second is unchanged
C. Both timestamps become missing values
D. The first is shifted and the second is NaT

57 What tuple results from ("-42".zfill(5), "-42".rjust(5, "0"))?

Formatting Hard
A. ("00-42", "-0042")
B. ("-0420", "-0042")
C. ("00-42", "-0420")
D. ("-0042", "00-42")

58 q = Decimal("-0.004").quantize(Decimal("0.01"), rounding=ROUND_HALF_UP) formats as -0.00. Which operation removes the negative-zero presentation without altering nonzero values?

Formatting Hard
A. Set q = abs(q) only when q == 0
B. Set q = Decimal(0) when q < 0
C. Set q = -q when q < 0
D. Set q = abs(q) for every value

59 Which read_csv call preserves both 0012 and the literal text NA from StringIO("id\n0012\nNA\n")?

Formatting Hard
A. pd.read_csv(buf, keep_default_na=False)
B. pd.read_csv(buf, na_filter=True, converters={"id": int})
C. pd.read_csv(buf, dtype={"id": "string"})
D. pd.read_csv(buf, dtype={"id": "string"}, keep_default_na=False)

60 What does pd.Timestamp("2024-01-01 00:30", tz="UTC").tz_convert("America/New_York").strftime("%Y-%m-%d") return?

Formatting Hard
A. "2023-12-30"
B. "2023-12-31"
C. "2024-01-02"
D. "2024-01-01"