Chapter 1 · Section 1 practice

Series Foundations

0 of 6 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

What does alist.mean() do?

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

Question 3

Which pair returns the January and May figures?

  • sales.loc[0] and sales.loc[4]
  • sales.loc["Jan"] and sales.iloc[-1]
  • sales.iloc["Jan"] and sales.iloc["May"]
  • sales.iloc[1] and sales.iloc[-1]

Question 4

cross_section is ordered AAPL, MSFT on 5 February. If you divide MSFT’s value by the preceding row’s value, what are you comparing?

  • MSFT today with MSFT yesterday
  • AAPL today with AAPL yesterday
  • MSFT’s stored price with AAPL’s stored price on the same date
  • It automatically groups observations by stock

Question 5

pd.Series([1,2,3,4]) + pd.Series([100,200,300]) gives …

  • ValueError: lengths differ
  • Three values — the extra one is dropped
  • Four values — the last one is NaN
  • Four values — the last one is 4

Question 6

For the same data, how does price.std() compare with price.std(ddof=0)?

  • Slightly larger — pandas divides by \(n-1\) by default
  • Slightly smaller — pandas divides by \(n\) by default
  • Identical — ddof only affects .var()
  • Undefined — ddof must always be given