How can I group by two columns interchangeably?
For example, if I have this table
and I want to get
However, I get this instead when I use
df.insert(2, 'Count', df.groupby(['Name1','Name2'])['Name1'].transform('size'))
The entries (rows) that have the same names but exchanged are considered to be new entries, but i want to treat them the same way, can you please tell me a way to do this?