I have a dataframe that looks as follows:
df = pd.DataFrame({
'C1': ['A','A','A','B', 'B', 'C', 'C'],
'C2': [1, 2, 3, 1, 2, 1, 2],
'C3': [2., 3.1, 1.2, 1.4, 2.1, .4, .5]
})
I would like to filter the dataframe for individual combinations on C1 and C2.
For example, I would like to have the combination for the following matches: (C1 == 'A' & C2 == 2) and (C1 == 'B' & C2 == 1).
The resulting data frame should look as follows:
C1 C2 C3
0 A 2 3.1
1 B 1 1.4
So, I would like to filter on the unique combinations, e.g. given by a list of tuples. For the above example it would look like this:
[('A', 2), ('B', 1)]
Can you guide me how I can accomplish this ideally not using a loop?
Thank you.
Philipp