In the following dataframe I have 3 columns, index, adj, and typ. the TYP column relates to the index. So every (x,1) multiindex has a value of PWR, and every (x,2) multiindex has a value of GND.
index Adj TYP
(x,1) (x, 2) PWR
(x,1) (x, 3) PWR
(x,1) (x, 5) PWR
(x,1) (x, 6) PWR
(x,1) (x, 7) PWR
(x,2) (x, 1) GND
(x,2) (x, 3) GND
(x,2) (x, 4) GND
(x,2) (x, 5) GND
(x,2) (9, 6) GND
(x,2) (x, 7) GND
I want to figure out how to use the relationship between index and TYP to populate a fourth column called 'Adj. TYP'. This column will have the relationship between ADJ and TYP. If we were doing it for only indices (x,1) and (x,2) the resulting table would be below. This is cumbersome to explain in text but essentially the Adj column contains the same data as the index column, just not really in the same order. I want to populate the 4th column with the matching TYP.
index Adj TYP Adj. TYP
(x,1) (x,2) PWR GND
(x,1) (x,3) PWR
(x,1) (x,5) PWR
(x,1) (x,6) PWR
(x,1) (x,7) PWR
(x,2) (x,1) GND PWR
(x,2) (x,3) GND
(x,2) (x,4) GND
(x,2) (x,5) GND
(x,2) (9,6) GND
(x,2) (x,7) GND
I have attempted to use map, but this won't let me reindex a multivalued index.
df1['Adj. TYP'] = df1['Adj'].map(df1[index])