I have a pandas dataframe with 5 columns and 3 of those columns are string columns. I want to trim all the leading and trailing whitespaces in those 3 columns. Is there a way to achieve this in one go.
ID col_1 col_2 col_3 col_4
0 1 AA XX 200 PP
1 2 BB YY 300 QQ
2 3 CC ZZ 500 RR
I want to trim 'col_1', 'col_2', 'col_4'
I know df['col_1'].str.strip() works on a individual column. But can i do all the columns at one go?