I have a dataframe formatted like this in pandas.
(df)
School ID Column 1
School 1 AD6000
School 2 3000TO4000
School 3 5000TO6000
School 4 AC2000
School 5 BB3300
School 6 9000TO9900
....
All I want to do is split column 1 rows that have the word 'TO' in it as a delimiter into two new columns while leaving the original. The result would be this.
(df)
School ID Column 1 Column 2 Column 3
School 1 AD6000 NaN NaN
School 2 3000TO4000 3000 4000
School 3 5000TO6000 5000 6000
School 4 AC2000 NaN NaN
School 5 BB3300 NaN NaN
School 6 9000TO9900 9000 9900
....
Here's the code I have that I thought works, but it turns out it is leaving blanks in columns 2 and 3 instead of splitting the numbers to the left and right of TO into their respective columns.
df[['Column 2','Column 3']] = df['Column 1'].str.extract(r'(\d+)TO(\d+)')
Thanks for the help.