Reputation:
Here is the code I am currently working with.
df['RESULT_DATE'] = df['RESULT'] + " , " + df['DATE'].astype(str)
grouped=df.groupby('PID')['RESULT_DATE'].apply(list)
gh=pd.DataFrame({'PID':grouped.index, 'RESULT_DATE':grouped.values})
vl=pd.DataFrame(gh.RESULT_DATE.values.tolist()).add_prefix('VL/DATE')
Running this code produces two strings separated by comma within the same column but I want these strings to be separated with two separate columns. So it would have "RESULT" and "DATE" as separated columns and there are 100 columns so looping through columns would be another possibility I think.
Upvotes: 0
Views: 43
Reputation: 86
To split one column into two by a separator try this:
df['RESULT_DATE'].str.split(' , ', expand=True)
Upvotes: 1