I have a dataframe dat1:
Asset Returns
DJ 0.1
SP 0.2
USDJPY 0.03
USDMXN 1.2
I have another dataframe dat2:
Country Class Asset
USA E DJ
USA E SP
USA FX USDJPY
USA FX USDMXN
How do I use dat2 to create an index for dat1; dat1 and dat2 have a common column "Asset"
>new_dat=dat_corr.merge(dat_class,on="Asset",how="right").set_index(['Country','Class','Asset'])
>new_dat.shape
(89, 89)
>temp1='UNITEDSTATES'
>temp2='Equity'
>new_dat.loc[ (new_dat.index.get_level_values('Country').isin([temp1]) & new_dat.index.get_level_values('Class').isin([temp2]))]'
This gives me [3 rows x 89 columns]. My 89 columns is a mix of Equity/FX/FI/Commodities. If I want only USA Equities vs all other equity and not the entire 89 columns how do I do it? So I thought if I can create an index for the columns as well and use a similar approach?