0

I have a list of Pandas dataframes:

df_list = [df1, df2, df3]

The dataframes have the same column names; let's call them "col1", "col2" and "col3".

How can I change the column names to "colnew1", "colnew2" and "colnew3", without using a loop?

1 Answers1

1
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
df.rename(columns={"A": "a", "B": "c"})
   a  c
0  1  4
1  2  5
2  3  6

This is taken right from the pandas website.

unltd_J
  • 476
  • 7
  • 14