I have the following dataframe:
d = {'col1':['a','b','c'],'col2':['x1;x2;x3','x5','x6'],'col3':['y1','y2,y3,y4','y5']}
df = pd.DataFrame(d)
I want to choose a column and split that into multiple rows, for instance if I choose col2 I expect the result to be the output of the following:
d = {'col1':['a','a','a','b','c'],'col2':['x1','x2','x3','x5','x6'],'col3':['y1','y1','y1','y2,y3,y4','y5']}
df = pd.DataFrame(d)
and if I choose col3 I expect:
d = {'col1':['a','b','b','b','c'],'col2':['x1;x2;x3','x5','x5','x5','x6'],'col3':['y1','y2','y3','y4','y5']}
df = pd.DataFrame(d)
Note that in col2, x are separated by ; while in col3, y are separated by ,. I have tried .explode but that did not give the results I've shown above.