I want to replace some characters in column names at scale and I was able to do it through columns with str.replace(). However, I want to know if I could do this through lambda functions so I could bring them into my other pandas workflow instead of doing it independently.
dat.columns = (
dat.columns
.str.replace(r"park_1_city", "us1state")
.str.replace(r"park_2_city", "us2state")
.str.replace(r"park_3_city", "us3state")
.str.replace(r"us1tree", "us1garden")
.str.replace(r"us2tree", "us2garden")
.str.replace(r"us3tree", "us3garden")
)