I have dataframe and want to count how many times the name appears in both columns
data=pd.DataFrame({'TEAM 1':['Mark','Peter','Andy','Tony'],'Team 2':
['Andy','Tony','Jhon','Peter']})
so the name Andy would count as 2, while Jhon is 1
Expected Output
Mark 1
Andy 2
Tony 2
Jhon 1
Peter 2
I used this code but it does not work
data.groupby('TEAM 1')['Team 2'].count()