I have a dataframe df of the following type:
ID   Result Other_val
1    A      y
2    B      x
2    A      x
3    C      abc
After using pd.crosstab(df.ID, df.Result), I get a crosstab like this:
Result  A  B  C
ID
1       1  0  0
2       1  1  0
3       0  0  1
I wish to now concatenate these values to the end of my original dataframe (after removing the already present Result column) to get something like this:
ID   A   B   C   Other_val
1    1   0   0   y
2    1   1   0   x
3    0   0   1   abc
However, I am stumped. I can't seem to use pd.concat() to form the above table because of the strange way the cross-tab table is indexed.
Any help?
 
     
    