I have the following example DataFrame:
df = pd.DataFrame({'col1': ['A', 'A', 'B', 'A', 'B', 'B', 'A', 'B', 'B', 'A'], 'col2': [0, 0, 1, 1, 0, 1, 0, 0, 0, 0]})
Now, I would like to create a second DataFrame containing only the rows from df
where:
col1 - A matches col2: 0 and col1 - B matches col2: 1
df2 = pandasDataFrame({'col1' : ['A', 'A', 'B', 'B', 'A', 'A'], 'col2' : [0, 0, 1, 1, 0, 0]})
I have tried with query, but it is only working on one condition, if I separate condition pair in parenthesis, I get an empty DataFrame.