I've encountered a situation where I need to filter a dataframe via input(s) that are found in columns P1-P5 below. There could be anywhere from 1 to 5 inputs and they could be located in any of P1-P5.
TeamAbb P1 P2 P3 P4 P5
0 ATL1 203953 1627745 1629027 1629629 1629631
1 ATL2 203953 1627745 1627761 1629027 1629631
2 ATL3 203458 203953 1627761 1629027 1629631
3 ATL4 203458 203953 1629027 1629629 1629631
4 ATL5 203458 1628381 1629027 1629629 1629631
5 ATL6 203953 1628981 1628989 1629027 1629631
6 ATL7 203953 1627745 1628989 1629027 1629631
7 ATL8 1713 202323 203459 1627761 1628981
8 ATL9 1713 203459 1628981 1629027 1629631
Example 1
input_val = [1713]
TeamAbb P1 P2 P3 P4 P5
7 ATL8 1713 202323 203459 1627761 1628981
8 ATL9 1713 203459 1628981 1629027 1629631
Example 2
input_val = [1713,202323]
TeamAbb P1 P2 P3 P4 P5
7 ATL8 1713 202323 203459 1627761 1628981
So far each method I've tried hasn't worked (query, apply/any and mask). If anyone has ideas on how to approach this I'd really apreciate it.