Skip to main content

All my columns are indexes in pandas. How to solve that and 'reset' the index?

So, When i do print(mydf.columns) with my one of my dataframes, i get this result:

Index([
   'facility', '2022-01-01', '2022-02-01', '2022-03-01', '2022-04-01', 'YTD', 'state_name'
   ],
   dtype='object'
)

And because of that I can't join this dataframe with another one because i simply cannot specify which column i want to use as join parameter. To get that dataframe, i used this command:

mydf = mydf[(mydf['facility'] != "Insert New ") & (mydf['facility'] != "Total")]

How can i fix this?



source https://stackoverflow.com/questions/72680042/all-my-columns-are-indexes-in-pandas-how-to-solve-that-and-reset-the-index

Comments