I have a dataframe like as shown below
df = pd.DataFrame({'val': ['V583 ,ATTENTION, PRIMARY','Y9207,INDOOR LIVING, sEcondary',' z526, liver,primary ','12345678, test, secondary',',project,']})
I would like to split/segregate column val data based on comma character.
For instance, All characters before 1st comma should go to first column
Similarly, All characters after 1st comma and before 2nd comma should go to second column
likewise, All characters after 2nd comma and before 3rd comma should go to third column
I tried the below
df['val'].astype(str).str.extract(r'\s*([a-zA-Z0-9\s]*)',expand=True)
I expect my output to be like as shown below
