Skip to content Skip to sidebar Skip to footer

How To Pivot A Dataframe With Pandas So Variable Columns Become Rows?

I currently have the following dataframe: Current df: type part number part description waiting period hours 0 service item SOME-X1R-1807

Solution 1:

I do not think this is pivot

df.set_index('part number').T
Out[214]: 
part number         SOME-X1R-1807  RANDOM-462-1171     PART-7W-2326  \
            type     service item       CONSUMABLE            wheel   
part description             SOME       ESCRIPTION        ABOUT THE   
waiting period              1 day           6 days           7 days   
hours                          24              144              168   
part number        NUMBER-1R-0762   NUMBER-XL-0747  
            type             tyre            other  
part description   PARTS FROM THE  PREVIOUS COLUMN  
waiting period             8 days           9 days  
hours                         192              216  

Post a Comment for "How To Pivot A Dataframe With Pandas So Variable Columns Become Rows?"