Columns display wierd naming after resetting multi index back to columns

piza25

So I have been working with a dataframe and converted it to long to wide setting a multi index.

df_wide = df.pivot_table(index = ["StationId", "day", "month", "year", "hour", "dayofweek"], columns = "minute", values = ["StationTotalFlow"])

I then used reset_index to reuse the columns I originally multi indexed.

df_wide = df_wide.reset_index()

My dataframe now looks like this(screenshot):

dataframe screenshot

I would like to remove that minute index and... Using

df_wide.info()

I notice my column names are wrapped in parentheses.

.info screenshot

Does anyone know what is going on?

John Zwinck

It's not that they're "wrapped in parentheses" really, it's that you went from a MultiIndex to a single-level list of names, so the first level of the MultiIndex became the first element of each tuple, and the second level became the second element of each tuple.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related