0

I'm trying to work on an analysis of World of Warcraft gear and I'm having an issue with grouping. I can group all unique helms (head-gear) and count them by name. However, in-game your character can wear 2 rings. From the API this comes up as Ring 1 and Ring 2, the order does not matter but I would like to group the combination and count occurences.

Problem

The 2 same rings on different fingers/slots will appear as 2 separate counts.

data = [['Death God\'s Signet', 'Stitchflesh\'s Misplaced Signet', 12],
        ['Stitchflesh\'s Misplaced Signet','Death God\'s Signet', 13],
        ['Sinful Gladiator\'s Ring','Death God\'s Signet', 13]]
df = pd.DataFrame(data, columns = ['Ring 1', 'Ring 2', 'count']) 

Results

Goal

I want it to be grouped regardless of combination order. Like so,

enter image description here

Attempts

I've tried:

  • Combining them as a list but it still has the same problem.
  • Zipping them and sorting by values (like here)
  • Sorting alphabetically and then grouping/making a list/ zipping
Fiery-Skyline
  • 67
  • 1
  • 4

1 Answers1

1

you can sort the Ring text with this syntax

df['Ring 1'],df['Ring 2']=df[["Ring 1", "Ring 2"]].max(axis=1),df[["Ring 1", "Ring 2"]].min(axis=1)
Bing Wang
  • 1,548
  • 1
  • 8
  • 7