Chapter 2 quiz

DataFrames

0 of 10 answered

These questions review the examples in the companion slides. Choose an answer, then check the explanation.

Question 1

Which selection returns a Series from df?

  • df["AEP"]
  • df[["AEP"]]
  • df.loc[:, ["AEP"]]
  • df.head()

Question 2

What does df.isna().sum() report by default?

  • Missing-value counts for each column
  • The number of complete rows
  • The column means
  • Only repeated observations

Question 3

Which operation returns one group mean aligned to each original row?

  • groupby(...).transform("mean")
  • groupby(...).mean()
  • groupby(...).size()
  • drop_duplicates()

Question 4

Why can ordinary steps and a short chain give the same table?

  • They perform the same operations on the same input in the same order
  • A chain always removes missing values
  • Chaining changes the formula
  • A chain ignores the row index

Question 5

In px.scatter(df, x="teaching", y="citations"), what do x and y name?

  • DataFrame columns
  • Row positions
  • Python package names
  • Two output files

Question 6

A table has 5 rows and 3 numeric columns. How many values does df.mean(axis=0) return?

  • 5
  • 15
  • 1
  • 3

Question 7

What does df.dropna(subset=["price"]) retain?

  • Only rows with every column observed
  • Only columns without missing values
  • Rows where price is missing
  • Rows with an observed price, regardless of missing values in other columns

Question 8

A stock appears in many months. Which columns should match its monthly sector table?

  • ticker alone
  • date alone
  • current row position
  • ticker and date together

Question 9

Which write updates the selected cells of the original table?

  • df.loc[mask]["flag"] = True
  • df[mask]["flag"] = True
  • df.copy()["flag"] = True
  • df.loc[mask, "flag"] = True

Question 10

What should be checked before plotting a numeric column?

  • Only the chart colour
  • Whether its name is short
  • Whether every value is positive
  • Its meaning, numeric type, missing values and selected rows