There are other questions on the same topic and they helped but I have an extra twist.

I have a dataframe with multiple values in each (but not all) cells.

```
df = pd.DataFrame({'a':["10-30-410","20-40-500","25-50"], 'b':["5-8-9","4", "99"]})

```

| index | a | b |
| --- | --- | --- |
| 0 | 10-30-410 | 5-8-9 |
| 1 | 20-40-500 | 4 |
| 2 | 25-50 | 99 |

How can I split each cell by the dash "-" and create three new dataframes? Note that not all cells have multiple values, in which case the second and third dataframes get NA or blank (treating these as strings).

So I need df1 to be the first of those values:

| index | a | b |
| --- | --- | --- |
| 0 | 10 | 5 |
| 1 | 20 | 4 |
| 2 | 25 | 99 |

And df2 would be:

| index | a | b |
| --- | --- | --- |
| 0 | 30 | 8 |
| 1 | 40 |  |
| 2 | 50 |  |

And likewise for df3:

| index | a | b |
| --- | --- | --- |
| 0 | 410 | 9 |
| 1 | 500 |  |
| 2 |  |  |

I got df1 with this

```
df1 = df.replace(r'(\d+).*(\d+).*(\d+)+', r'\1', regex=True)

```

But df2 doesn't quite work. I get the second values but also 4 and 99, which should be blank.

```
df2 = df.replace(r'(\d+)-(\d+).*', r'\2', regex=True)

```

| index | a | b |
| --- | --- | --- |
| 0 | 30 | 8 |
| 1 | 40 | 4 - should be blank |
| 2 | 50 | 99 - should be blank |

Is this the right approach? I'm pretty good on regex but fuzzy with groups. Thank you.