I have a dataframe as below :
A B
0 33590104 3359017;3359011;3359031
1 53340311 5334012
2 160750035 16075131;16075132;16075135;16075046
3 10510044 1051012;1051097;1051010;1051051;1051089;105106...
4 51540061 5154036
I want to have rows for each value in A with every value in B that is separated by ';' like below
A B
33590104 3359017
33590104 3359011
33590104 3359031
53340311 5334012
160750035 16075131
160750035 16075132
160750035 16075135
160750035 16075046
and so on....
My idea is to first convert the string in column B into a list. for example :
A B
0 33590104 [3359017,3359011,3359031]
1 53340311 [5334012]
2 160750035 [16075131,16075132,16075135,16075046]
And then use the explode function. But I don't know how I can convert string with delimiter ';' to a list. Also I don't know exactly how many strings are separated by ';' in each row. It varies for each row as you can see in the example above.