How it works...

We address each transformation separately:

Deflation: In Step 2, we used the cpi library to account for inflation in the US dollar. The library relies on the CPI-U index recommended by the Bureau of Labor Statistics. To make it work, we created an artificial index column containing dates as objects of the datetime.date class. The inflate function takes the following arguments:

  • value: The dollar value we want to adjust.
  • year_or_month: The date that the dollar value comes from.
  • to: Optionally, the date we want to adjust to. If we don't provide this argument, the function will adjust to the most recent year.

Log transformation: In Step 3, we applied the natural logarithm (np.log) to all the values to make the exponential trend linear. This operation was applied to prices that had already been corrected for inflation.

Taking the first difference: In Step 5, we used the diff method to calculate the difference between the value in time t and time t-1 (the default setting corresponds to the first difference). We can specify a different number by changing the period argument.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.236.96