Multiple search/replace on pandas series I have a pandas dataframe with school names as one of the columns. However, there is quite a bit of misspelling in the school names, for example:

'Abernethy Elem School', 'Abernethy Elementary School', 'BOISE/ELIOT ELEM SCHOOL', 'Boise/Eliot Elementary School', 'Boise-Eliot Elementary School' ...

I am trying to clean up the names by doing this:

school_perf_report["SCHLNM"] = school_perf_report["SCHLNM"].str.lower().str.replace(r"elementary","elem").str.replace(r"/"," ").str.replace("-"," ").str.replace(r"\s+"," ")


Is there some cleaner way to perform the same operation? Basically


Change "elementary" to "elem" 
Remove / or - and replace them with space. 
Remove multiple spaces 
Lower case everything


Thanks
Create a definition for string replacements:

def change_string(x):
    return x.replace('|', '_').replace("elementary","elem").replace('old_value', 'new_value)


Then use map command to perform operation on entire column:

# You could create a new column to check whether the output is as expected
# If it is as expected, you could modify the original column
school_perf_report["SCHLNM_MODIFIED"] = school_perf_report["SCHLNM"].map(lambda x: change_string(x))


Hope this helps.