Chapter 1 quiz

Data Structures and Methods of Series

0 of 10 answered

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

Question 1

With the three-row table above, what does intro_table[[β€œPriceReg”]] return?

  • A Series with shape (3,)
  • A DataFrame with shape (3, 1)
  • A list of three prices
  • A single price

Question 2

price.where((price >= 50), other=0) returns …

  • Same length; prices β‰₯ 50 kept, the rest set to 0
  • Only the prices β‰₯ 50 (shorter Series)
  • Same length; prices β‰₯ 50 set to 0
  • Prices < 50 dropped, the rest set to 0

Question 3

How many rows do aep.loc[β€œ2017-01-01 01:00”:β€œ2017-01-01 05:00”] and aep.iloc[0:5] return?

  • 4 and 5
  • 5 and 5
  • 5 and 4
  • 4 and 4

Question 4

weather[β€œdate”].iloc[0] right after pd.read_csv is a …

  • str
  • Timestamp
  • datetime64
  • int (days since 1970)

Question 5

Which object owns the title and y-axis label of one subplot?

  • The DataFrame index
  • The Axes
  • The NumPy random generator
  • The CSV file

Question 6

What does alist.mean() do?

  • Prints 320.0
  • Prints [300, 100, 0, 200, 1000]
  • Raises AttributeError β€” lists have no mean
  • Returns None

Question 7

dy.sum() and (dy + 1).isna().sum() give …

  • NaN and 0 β€” one hole poisons the sum, but adding 1 fills it
  • 48.28 and 1610 β€” the sum skips holes, the addition keeps them
  • NaN and 1610 β€” holes poison everything
  • 48.28 and 0 β€” holes are treated as 0 everywhere

Question 8

For jan = sp500.loc[β€œ2020”], do jan.loc[β€œ2020-01-06”:β€œ2020-01-08”] and jan.iloc[2:5] return the same rows?

  • Yes β€” Jan 6, 7, 8 both times, but for opposite slicing rules
  • No β€” .loc gives 2 rows, .iloc gives 3
  • No β€” .iloc includes Jan 9
  • They raise β€” you cannot mix index value and position

Question 9

msft.shift(1).iloc[0] is …

  • The first close
  • NaN
  • The second close
  • The last close

Question 10

In ax.hist(x, bins=50, density=True) the bars are scaled so that …

  • The tallest bar has height 1
  • The heights sum to 1
  • The total area of the bars is 1
  • The y-axis shows counts