what is the most elegant way to create a new dataframe from an existing dataframe, by 1. selecting only certain columns and 2. renaming them at the same time?
For instance I have the following dataframe, where I want to pick column B, D and F and rename them into X, Y, Z
base dataframe
A B C D E F
1 2 3 4 5 6
1 2 3 4 5 6
new dataframe
X Y Z
2 4 6
2 4 6
df.rename()to rename a certain subset of columns and then simultaneously index with the keys. Sod = {"B": "X", "D": "Y", "F": "Z"}and then simply do something likenew = df[list(d.keys())].rename(columns=d)