After several code attempts, I can't change the name of the columns on my excel documents.
import pandas as pd
FichierCible = r'C:\Users\User\Desktop\User\stack.xlsx'
df = pd.read_excel(FichierCible)
df.rename(columns={'a': 'A', 'b': 'B'}, inplace=True)
df
print(df)
Empty DataFrame
Columns: [A, B, c, d, e]
Index: []
The change is displayed correctly on the command prompt but on the Excel document the change is not applied. Do you have an idea ?
Thank you
CodePudding user response:
You need to write back your DataFrame to a new/the same Excel.
df.to_excel(FichierCible)