Skip to content
Quantoros

Create a DateTimeIndex consisting of the third Thursday in each month for the years 2015 and 2016. Assume import…

PythonLevel: Intermediate

Create a DateTimeIndex consisting of the third Thursday in each month for the years 2015 and 2016.

Assume import pandas as pd and import numpy as np.

Hints
  • First define row granularity, column types and keys.
  • Check index alignment, missing values and output size after the transformation.

Answer

pd.date_range('2015-01-01', '2016-12-31', freq='WOM-3THU')

Source and licence: 100 pandas puzzles — Alex Riley and contributors · MIT

Related questions