I have 3 Datasets, Each with 3 columns and over 1000 rows. Data is about the count of a combination of 2 symptoms. For example, Pain and Fever with a count of 2. I want an output where these DataFrames are combined in such a way that the count of common symptoms from different DataFrames are summed up and non-common combinations are joined just the way they are. I am attaching a sample DataFrame and the result I want. Help will be appreciated.
#Sample
a = pd.DataFrame({'a':['pain','fever','Headache'],'b':['Cancer','HIV','Piles'],'count':[2,4,5]})
b = pd.DataFrame({'a':['pain','Pyrexia','Headache'],'b':['Cancer','HIV','Piles'],'count':[1,5,7]})
c = pd.DataFrame({'a':['pain','fever','Cancer'],'b':['Cancer','HIV','Piles'],'count':[2,4,5]})
This is the result I want after they have been combined:
#Result
result = pd.DataFrame({'a':['pain','fever','Headache','Pyrexia','Cancer'],\
'b':['Cancer','HIV','Piles','HIV','Piles'],'count':[5,8,12,5,5]})
result
a b count
0 pain Cancer 5
1 fever HIV 8
2 Headache Piles 12
3 Pyrexia HIV 5
4 Cancer Piles 5