import pandas as pd
df = pd.read_excel("BSI Values.xlsm",sheet_name = "Sheet1")
df.head()
### I first sort my sales and I am going to use inplace = True so I can save the df as it's sorted inplace df.sort_values(by="sales",ascending = False,inplace = True)
### Create your excel writer writer = pd.ExcelWriter("BSI Values.xlsx") #Now I can save my df using this writer df.to_excel(writer) ##and now I can close my writer writer.close()
df.set_index("Current Period",drop=True, inplace=True)
in the method above I used drop=True , this means you can go ahead and remove the previous index values. I also used inplace=True which is a convenient method, to save inplace, found in a lot of Pandas method.