I want to separate the conditions that exist in the ID column. What should I do in this case?
I wrote it as below, but there is a problem that it is not separated in the desired direction.
df['and'] = df['ID'].str.extract(r'\((.*?)\)', expand = False)
df['test'] = np.where(df['ID'].str.contains('or'), df['ID'].str.split('or'), None)
ID Note and test
A or B or (C & D) NaN C & D [A , B , (C & D)]
E or F & (G & H) NaN G & H [E , F & (G & H)]
W or X or Y or Z NaN NaN [W , X , Y , Z]
What should I do for to get this result?
| ID | Note | And | Or |
| -------- | -------- | -------- | -------- |
| A or B or (C & D) | | C, D | A, B |
| E or F & (G & H) | | F, G, H | E |
| W or X or Y or Z | | | W, X, Y, Z |