How to split this column into 2 or more columns. I've used str.split('/',2) to split but it just removed the '/' and did not split into 2 columns.
| X |
|---|
| East Bound: 6900 / West Bound: 7700 |
| East Bound: 7800 / West Bound: 8700 |
| North Bound: 5000 / South Bound: 4900 |
| North Bound: 7000 / South Bound: 9000 |
| East Bound: 4900 / West Bound: 9700 |
What I want is:
| First Direction | Second direction |
|---|---|
| East Bound: 6900 | West Bound: 7700 |
| East Bound: 7800 | West Bound: 8700 |
| North Bound: 5000 | South Bound: 4900 |
| North Bound: 7000 | South Bound: 9000 |
| East Bound: 4900 | West Bound: 9700 |
Even better is if I can have four column headers for the four cardinal directions and filling it with the values from the first table such as:
| North | South | East | West |
|---|---|---|---|
| 0 | 0 | 6900 | 7700 |
| 0 | 0 | 7800 | 8700 |
| 5000 | 4900 | 0 | 0 |
| 7000 | 4900 | 0 | 0 |
| 0 | 0 | 4900 | 9700 |
If I have read on the documentation correctly, I believe this can be done with regex patterns but is there an efficient way to do this concisely?
Here is the original df for use:
df = ['East Bound: 6900 / West Bound: 7700', 'East Bound: 7800 / West Bound: 8700', 'North Bound: 5000 / South Bound: 4900', 'North Bound: 7000 / South Bound: 9000', 'East Bound: 4900 / West Bound: 9700']
expand (bool), default False: Expand the split strings into separate columns?