0

I have a dataframe with several hundred items each with a group number and a rank. I would like to put a nice looking table which arranges into a grid of ranks across the top and groups up and down. Each intersection (ie a given group and rank) could have no items or several items. So size of each cell/intersection would have a variable length.

See image attached - dataframe at top and desired output in bottom.

enter image description here

Chris L
  • 319
  • 1
  • 3
  • 10
  • Use this one: ```df = pd.DataFrame({"Items":["item1", "item2", "item3", "item4"], "Group":["A", "A", "A" ,"C"], "Rank":[1,1,2,3]}) df.pivot_table(index="Group", columns="Rank", aggfunc=list)``` – ashish14 Apr 27 '19 at 15:43
  • @ashish14 - thanks. That works. The only issue is that within box the items are listed as [item1,item2, etc...] instead of vertically without the square brackets. Any way to change that? – Chris L Apr 27 '19 at 16:53

0 Answers0