I've got a pandas DataFrame that uses "2Nd" instead of "2nd", "136Th" instead of "136th", etc. I want the letter immediately following the number to be lowercase.
Sample data:
data = pd.Series(['21St StNew York', 'Exampe BlvdSt Louis', '1St Rd'])
Desired output:
['21st StNew York', 'Exampe BlvdSt Louis', '1st Rd']
Tried using str.replace():
data = data.str.replace('\BSt', 'st', regex=True)
['21st StNew York', 'Exampe Blvdst Louis', '1st Rd']
Is it possible to use a capture group?
data = data.str.replace('[0-9]+(St)', 'st', regex=True)
['st StNew York', 'Exampe BlvdSt Louis', 'st Rd']