So I have a pandas column that looks like this:
full_name = pd.Series([
'Reservoir 1 Compartment 1',
'Reservoir 1 Common Inlet',
'Reservoir 2 Compartment 1',
'Vyrnwy Line 2 Balancing Tank 1',
'Reservoir 1'
])
I am trying to split it into two columns. The expected output should look like this:
[['Reservoir 1', 'Compartment 1'],
['Reservoir 1', 'Common Inlet'],
['Reservoir 2', 'Compartment 1'],
['Vyrnwy Line 2', 'Balancing Tank 1'],
['Reservoir 1', None]]
I have tried this:
res_compartment_split = pd.concat([full_name.str.split(r'\s\s*?(?=[A-Z])', expand=True)])
but I get this output
[['Reservoir 1', 'Compartment 1', None, None],
['Reservoir 1', 'Common', 'Inlet', None],
['Reservoir 2', 'Compartment 1', None, None],
['Vyrnwy', 'Line 2', 'Balancing', 'Tank 1'],
['Reservoir 1', None, None, None]]
Thanks for any help.