Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. # A new DataFrame including only the three feature ["10_yrs_rt","3_mth_rt","cpi_index"] is created
  2. df_slope=features.loc[:,["10_yrs_rt","3_mth_rt","cpi_index"]]
  3. # First the features slope is created
  4. df_slope["slope"]=df_slope["10_yrs_rt"]-df_slope["3_mth_rt"]
  5. # Then the 3 months change of the "slope" is added
  6. df_slope["d_slope_3m "]=df_slope["slope"].diff(3)
  7. # Eventually the 6 months change of the "slope" is added
  8. df_slope["d_slope_6m "]=df_slope["slope"].diff(6)
  9. # the feature "cpi" is created:
  10. df_slope["cpi"]=df_slope["cpi_index"].pct_change(12).mul(100)
  11. # the feature "real_rate" is generated with its 3 and 6 months changes:
  12. df_slope["real_rate"]=df_slope["3_mth_rt"]-df_slope["cpi"]
  13. df_slope["d_rr_3m"]=df_slope["real_rate"].diff(3)
  14. df_slope["d_rr_6m"]=df_slope["real_rate"].diff(6)
  15. df_slope.drop(["10_yrs_rt","3_mth_rt","cpi_index","cpi"],axis=1,inplace=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement