s = """
country1   country2   pair      volume
USA        CHN        USA_CHN   10
CHN        USA        CHN_USA   5
AFG        ALB        AFG_ALB   2
ALB        AFG        ALB_AFG   5
"""
data = pd.read_table(io.BytesIO(s), sep='\\s+')
key = data[['country1', 'country2']].apply(frozenset, 1)
print(data.groupby(key).sum())
Combining similar rows in Stata / python