I created one new data frame by using one list and column value, and I successfully renamed the Index name but I'm not able to rename the first column name, I tried all the possible methods that I know (I want to rename this column name O with date, I tried all methods but it won't work as you can see in code snap)
datebucket=[]
def Walmart(data,stateAbb):
Walmart_df=pd.DataFrame(data)
Walmart_df=Walmart_df[Walmart_df['STRSTATE']== stateAbb]
date=Walmart_df.sort_values(by='date_super').groupby(['STRSTATE','date_super'])
['date_super']
test=date.first().index
for i in test:
datebucket.append(i[1])
cumsum=Walmart_df.groupby(['STRSTATE','date_super']).count()['storenum']
NewDf=pd.DataFrame(datebucket,cumsum)
NewDf.index.names = ['cumsum']
NewDf.rename(columns = {'0':'date'}, inplace = True)
NewDf.rename(columns={NewDf.columns[0]: 'new'})
NewDf.dropna()
display(NewDf)
Walmart(df,'TX')