1. Learn
  2. /
  3. Courses
  4. /
  5. Manipulating Time Series Data in Python

Connected

Exercise

Your first time series

You have learned in the video how to create a sequence of dates using pd.date_range(). You have also seen that each date in the resulting pd.DatetimeIndex is a pd.Timestamp with various attributes that you can access to obtain information about the date.

Now, you'll create a week of data, iterate over the result, and obtain the dayofweek and day_name() for each date.

Instructions

100 XP

We have already imported pandas as pd for you.

  • Use pd.date_range to create seven dates starting from '2017-1-1' at (default) daily frequency. Use the arguments start and periods. Assign the result to seven_days.
  • Iterate over each date in seven_days and in each iteration, print the .dayofweek and .day_name() attributes.