Home > Blockchain >  How to hide the index column of a pandas dataframe?
How to hide the index column of a pandas dataframe?

Time:12-26

Help please, I need to delete the 'date' index column, or else 'date' will appear in the first column with the actions

enter image description here


heat_ds = pd.DataFrame(columns=['PFE','GS','BA','NKE','V','AAPL','TSLA','NVDA','MRK','CVX','UNH'])

heat_ds['PFE'] = pfizer['Close']

heat_ds['GS'] = goldmans['Close']

heat_ds['BA'] = boeingc['Close']

heat_ds['NKE'] = nike['Close']

heat_ds['V'] = visa['Close']

heat_ds['AAPL'] = aaple['Close']

heat_ds['TSLA'] = tesla['Close']

heat_ds['NVDA'] = tesla['Close']

heat_ds['MRK'] = tesla['Close']

heat_ds['CVX'] = chevronc['Close']

heat_ds['UNH'] = unitedh['Close']

CodePudding user response:

First of all date represents index. To drop it first reset index to remove date from index of dataframe and make it a normal column and then drop that column.

heat_ds = heat_ds.reset_index()
heat_ds = heat_ds.drop('index', axis=1)

or in one line

 heat_ds = heat_ds.reset_index(drop=True)
  • Related