I have a dataframe that looks like this:
df = pd.DataFrame({"ID": ["P-1", "P-2", "P-3"], "Acc No": ['11234/57468/28576', '13245/13246', '46578/37264/35264'], "Company": ["red", "yellow", "blue"]})
print(df)
I would like to split out the 'Acc No' column so that each entry keeps the data from the remaining columns e.g.
df2 = pd.DataFrame({"ID": ["P-1","P-1","P-1", "P-2","P-2", "P-3","P-3","P-3"], "Acc No": ['11234','57468','28576', '13245','13246', '46578','37264','35264'], "Company": ["red", "red","red","yellow", "yellow", "blue", "blue", "blue"]})
print(df2)
I've tried splitting out the Acc No. column, which works but I can't find the correct way to match the new columns to the existing data.
How can I do this?