1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Inference in Python

Exercise

Sampling and point estimates

You have access to a small trading history of Bitcoin (BTC) and the S&P 500 (SP500). You decide to choose ninety consecutive days to analyze the percent growth of each asset over the same time period.

You'll start by selecting an initial row number. To ensure that you get a sample of 90 consecutive rows, you'll need to select this starting row number from a range of values from zero to the length of btc_sp_df, excluding the last 90 rows. Your goal is to use this sample to better understand the growth of both assets in general.

The trading data has been loaded into btc_sp_df, as have the packages pandas as pd and NumPy as np.

Instructions 1/2

undefined XP
    1
    2
  • Use np.random.choice() to select an initial_row_number from a range of values that begins with zero and ends with the length of btc_sp_df, excluding the last 90 rows.
  • Select rows from initial_row_number to initial_row_number + 90 using .iloc.