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

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Bit of tweaking and it works the way I needed! Learned something new :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.