Given a pandas dataFrame, how does one convert several numeric columns (where x≠1 denotes the value exists, x=0 denotes it doesn't) into pairwise categorical dataframe? I know it is similar to one-hot decoding but the columns are not exactly one hot.
An example:
df
id A B C D
0 3 0 0 1
1 4 1 0 0
2 1 7 20 0
3 0 0 0 4
4 0 0 0 0
5 0 1 0 0
The result would be: df id match
result
0 A
0 D
1 A
1 B
2 A
2 B
2 C
3 D
5 B