I am working with 3 data frames, out of which 2 data frames contains additional bin number assigned to column data based on the range in which they belong (in separate columns).
df_1
A B
5 6
8 1
6 7
4 9
1 3
9 2
2 5
df_2
A B A_bin B_bin
5 6 2 2
8 1 1 1
6 7 3 2
4 9 3 3
1 3 1 1
9 2 1 1
2 5 2 2
df_3
A B C D A_bin B_bin C_bin D_bin
5 6 2 6 2 2 1 2
8 1 6 4 1 1 2 2
6 7 3 1 3 2 1 1
4 9 1 9 3 3 1 3
1 3 8 7 1 1 3 3
9 2 4 8 1 1 2 3
2 5 9 2 2 2 3 1
df_1 contain just two columns, df_2 have additional column which contain the bin assigned to column A and B according to the range in which the belong, similarly, df_3 contains columns with values and additional column with bin number assigned.
I want to extract the rows from df_3 such that it only extract data where df_2 columns have bin value "2" for each column respectively in a separate data frame.
The Main problem i am facing is to do it WITHOUT mentioning the column names anywhere in the code.
expected output
df_output_1 (where bin values for column 'A' in df_2 is 2)
A B C D
5 6 2 6
2 5 9 2
df_output_2 (where bin values for column 'B' in df_2 is 2)
A B C D
5 6 2 6
6 7 3 1
2 5 9 2