Reputation: 115
I have a dataframe with 558 columns in it. The first 12 columns are monthly sales, and the rest of the columns are characteristics of a product. Each row of the dataframe represents a single product.
I want to pivot the table so that the 12 sales columns for each product are representative rows for the product i.e. each product then will have 12 rows.
I thought the following code would work:
df.pivot(index=df[df.columns[0:11]] , columns=df[df.columns[12:558]])
But, no luck.
Appreciate any help!
Upvotes: 0
Views: 44