So i have this dataframe df1
Disease Gene1 Gene2 Gene3 Gene4
D1 0.1 1 26 1
D2 1 1 1 1
D3 1 18 0.5 17
D4 25 1 1 1
D5 1 1 1 1
D6 1 33 1 12
D7 1 0.3 1 1
D8 5 1 1 1
Also this dataframe df2
Gene1 Gene2 Gene3 Gene4
0 0 1 0
1 0 1 1
1 1 0 0
1 0 1 0
0 1 1 1
0 0 1 0
0 1 0 0
0 0 1 0
i want to multiply the values in df1 only if the 1 is present for that gene in df2. Please note not all the values are 1's in df1 some are decimals.
You can convert the int values to a boolean and then use this as a mask:
If you want to mask out the 'Disease' column then just use the other df columns to select the cols of interest:
EDIT
Semantically the following will handle where your other df has values other than
0
and1
: