Given the following dataframe:
import pandas as pd
names = ["(alpha, bravo, charlie, delta)", "(echo, foxtrot, golf, hotel)"]
vals = [2, 4]
df = pd.DataFrame(list(zip(names, vals)), columns=["name", "val"])
df
name val
0 (alpha, bravo, charlie, delta) 2
1 (echo, foxtrot, golf, hotel) 4
I want to make a new dataframe like
first second third fourth val
0 alpha bravo charlie delta 2
1 echo foxtrot golf hotel 4
All I know about the name column is that it's comma separated and enclosed in parenthesis, and that it's 4 items long. I get that this has to use regex, which is totally fine, but I don't know how to get multiple groups out of the same pandas column at the same time.
I imagine that this pattern would work, but I don't know how to implement it with pandas.
\(([^,]+),([^,]+),([^,]+),([^,]+)\)