I have a long list of suburbs that I want to do something to
A LOT of them have RDx (for rural Delivery) where x is a number from 1 to 30
I want to just get rid of the RDx like below
for row in WorkingData['PatientSuburb']:
if 'RD10' in str(row):
WorkingData['PatientSuburb'].replace(regex=True,inplace=True,to_replace=r'RD10',value=r'')
I was thinking If I could run a loop and increment the number somehow that'd be great. this wouldn't work but it's along the lines of what I'd like to do:
for rd in range(1,31,1):
if 'RD',rd in str(row):
WorkingData['PatientSuburb'].replace(regex=True,inplace=True,to_replace=r'RD'rd ,value=r'')
If I do this I get output with a space in between:
for rd in range(1,31,1):
print 'RD',rd
like so:
RD 1
RD 2
RD 3
RD 4
RD 5
RD 6
RD 7
RD 8
RD 9
RD 10
RD 11
RD 12
and also I would need to figure out how this piece would work...
to_replace=r'RD'rd
I have seen someone use a % sign in labelling a plot & then it brings in a value from outside the quotes - but I don't know if that's a part of the label function (I did try it and that didn't work at all) That would look like this
to_replace=r'RD%' % rd
Any help on this would be great thanks!