HW 2 Part 1

HW 2 Part 1

# TODO
# import the necessary packages

1.1 Following the example from the Data/1. APIs/Download data from ECB’s SDW notebook, fetch the table from ECB SDW link into a dataframe called hicp_codes. Set the index of the dataframe to the “Codes” column.

# TODO

#hicp_codes = ...

1.2 extract from hicp_codes a list of the codes of the same level 3 subindices assigned to you in HW1

Hint: a list comprehension may be useful here

## TODO

#codes = ...

1.3 Following the example from the Data/1. APIs/Download data from ECB’s SDW notebook, download the first series from your codes list into a dataframe. Rename the columns to date and the string in code[0]. Set date to be a datetime index and remove date from the dataframe columns.

## TODO

# code = codes[0]

1.4 Download the rest of the series from the list of codes into a single dataframe with index - the dates and column names given by the respective codes

Hint: this will (probably) require a loop. It may be a good idea to first try with only one additional series (e.g. code[1]) and see how to make sure that the merging works. And only then run the full loop. Following this approach, is often easier to discover errors in the code and fix them (i.e. to debug)

## TODO

1.5 for each series, print the fraction of missing values.

## TODO

1.6 create a new dataframe df_nona by dropping all columns in df that have more than half of their observations missing

## TODO

#df_nona = ...

1.7 which items were most and least volatile (i.e. max and min standard deviations) over the full sample period? Print their codes, code descriptions and the values of std for those items

Hint: use f-string and the hicp_codes dataframe you created earlier. Examples and information about f-strings can be found in the 02-Pandas-for-time-series notebook

## TODO

#item_code = ...
#item_code_descr = ...
#item_std =

#print(f-string here)

1.8 which items were most and least volatile over the last 24 months? Print their codes, code descriptions and the values of std for those items

## TODO

1.9 from df_nona compute the rolling window standard deviations for a window of 24 months, drop the missing values in the beginning of the sample and assign to a dataframe df_nona_roll_std

## TODO

#df_nona_roll_std = ...

1.10 plot in two separate plots the rolling window standard deviations for the most volatile items you identified above (full period and last 24 months)

## TODO