I have a data frame with many columns, some are objects including texts. I want to do some cleaning on all of the text columns like lower(), strip() etc. How can I get it by a loop over all text columns?
I have written this which works as I expect:
for column in t1.loc[:, t1.dtypes == np.object].columns:
t1.loc[:,column] = t1[column].str.lower().str.strip()
I was just wondering if there is a better way to write this. I am trying to improve my skills in pandas.