I have a dataframe which looks as follows:
# df
colA colB colC
rqp 129 a
pot 217;345 u
ghay 716 b
rbba 217;345 d
tary 612;811;760 a
kals 716 t
The ColB (any component out of two shown) & ColC combination make a unique combination. I want to create a dataframe from this dataframe which will look like the following
# newdf:
colAA coLBB
(129,a) (a,rqp)
(217,u) (u,pot)
(345,u) (u,pot)
(716,b) (b,ghay)
(217,d) (d,rbba)
(345,d) (d,rbba)
(612,a) (a,tary)
(811,a) (a,tary)
(760,a) (a,tary)
(716,t) (t,kals)
I have tried creating new columns if there is a single element in colB, but cannot get how to do using the semicolon splitter and then how to create columns of tuples.
If I do not have any semicolon in ColB, then I can use
df['AA'] = list(zip(df[colB], df[colC]))
df['AB'] = list(zip(df[colC], df[colA]))
However the presence of semicolon in ColB I am getting issues, as how to split that string into multiple ones and assign the tuples. Any help will be very much appreciated.