Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A new DataFrame including only the three feature ["10_yrs_rt","3_mth_rt","cpi_index"] is created
- df_slope=features.loc[:,["10_yrs_rt","3_mth_rt","cpi_index"]]
- # First the features slope is created
- df_slope["slope"]=df_slope["10_yrs_rt"]-df_slope["3_mth_rt"]
- # Then the 3 months change of the "slope" is added
- df_slope["d_slope_3m "]=df_slope["slope"].diff(3)
- # Eventually the 6 months change of the "slope" is added
- df_slope["d_slope_6m "]=df_slope["slope"].diff(6)
- # the feature "cpi" is created:
- df_slope["cpi"]=df_slope["cpi_index"].pct_change(12).mul(100)
- # the feature "real_rate" is generated with its 3 and 6 months changes:
- df_slope["real_rate"]=df_slope["3_mth_rt"]-df_slope["cpi"]
- df_slope["d_rr_3m"]=df_slope["real_rate"].diff(3)
- df_slope["d_rr_6m"]=df_slope["real_rate"].diff(6)
- 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