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