title: applying condition to rows DataFrame
body: <p>I have the following situation in the code:
  The data is stored in DataFrame with 3 columns. The filtering limits are stored in the dictionary. This dictionary can have one or more threshold limits to variables depending on the condition. if any one condition of the dictionary is meeting, the row is selected.</p>
  <pre><code>df = pd.DataFrame({'A': [1,2,3], 'B': [1,3,2], 'C': [1,0,3]})
  thres1 = {'A': 1, 'B': 1, 'C': 1}
  thres2 = {'A': 1, 'C': 1}
  </code></pre>
  <p>If thres1 is applied on df, it should return the second and third rows. If thres2 is used on df, it should return only the third row.</p>
  <p>I tried the apply, lambda, and query functions. After many efforts, I got workaround solution as below:</p>
  <pre><code>thres = thres1
  if (len(thres.keys()) == 2):
      p1, p2 = thres.keys()
      df = df[(df[p1] &gt; thres[p1]) | (df[p2] &gt; thres[p2])]
      
  elif (len(thres.keys()) == 3):
      p1, p2, p3 = thres.keys()
      df = df[(df[p1] &gt; thres[p1]) | (df[p2] &gt; thres[p2]) | (df[p3] &gt; thres[p3])]
  </code></pre>
  <p>This return the second and Third rows.</p>
  <pre><code>thres = thres2
  if (len(thres.keys()) == 2):
      p1, p2 = thres.keys()
      df = df[(df[p1] &gt; thres[p1]) | (df[p2] &gt; thres[p2])]
      
  elif (len(thres.keys()) == 3):
      p1, p2, p3 = thres.keys()
      df = df[(df[p1] &gt; thres[p1]) | (df[p2] &gt; thres[p2]) | (df[p3] &gt; thres[p3])]
  </code></pre>
  <p>This returns only the Third row.</p>
  <p>Is there any other way of implementing this efficiently? It'd be a great help!</p>