0

The sample dataframe df (which need to download from this link) includes 5 columns of data: date, US nominal GDP (quarterly), GDP Growth Tracker: YoY (weekly), World Container Freight Index (daily), Number of Container Ships (weekly), I now hope to convert all the columns' frequencies to the weekly level, in order to finally create a weekly economic activity index (approximate to the weekly nominal GDP).

I hope to use the script class TempDisagg in the timedisagg package to achieve it. How can I do it? Many thanks.

The dataset and test code we see now looks like this:

import pandas as pd
from timedisagg.td import TempDisagg

expected_dataset = pd.read_csv("./tests/sample_data.csv")

td_obj = TempDisagg(conversion="sum", method="chow-lin-maxlog")
final_disaggregated_output = td_obj(expected_dataset)

print(final_disaggregated_output.head()

Output:

    index grain X y y_hat
0 1972 1 1432.639 NaN 21.656879
1 1972 2 1456.891 NaN 22.219737
2 1972 3 1342.562 NaN 20.855413
3 1972 4 1539.394 NaN 23.937916
4 1973 1 1535.754 NaN 24.229008

References:

https://ec.europa.eu/eurostat/cros/content/chow-lin-method-temporal-disaggregation-method_en

https://github.com/christophsax/tempdisagg

Temporal Disaggregation of Time Series in Python

ah bon
  • 9,293
  • 12
  • 65
  • 148

0 Answers0