title: How to select rows in pandas based on a condition with a list?
body: <p>Let's say I have the following dataset:</p>
  <pre><code>x = [1, 1, 1, 2, 2, 2, 3, 3, 3]
  y = [1, 2, 3, 2, 3, 4, 3, 4, 5]
  import pandas as pd
  df = pd.DataFrame({'x':x,'y':y}) #dataframe to work with
  </code></pre>
  <p>which, plotted using matplotlib scatter looks like this.<a href="https://i.stack.imgur.com/230Bo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/230Bo.png" alt="enter image description here" /></a>
  I would like to select the bottom three points using Pandas, <strong>without iterating over the rows of my dataframe</strong> (because of speed considerations of a large dataframe), and without simply selecting 1st, 4th and 7th point of the dataframe:
  <a href="https://i.stack.imgur.com/ZBqxI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZBqxI.png" alt="fig2" /></a></p>
  <p>I tried selecting based on a condition:</p>
  <pre><code>selected_df = df.loc[df[&quot;y&quot;] &lt;=3] #selects an extra point at x=1,y=2
  </code></pre>
  <p>This selects an extra point which I don't want. I also tried building two lists of values representing a line that separates the bottom points from others:</p>
  <pre><code>x_line = [1,2,3]
  y_line = [1.5, 2.5, 3.5]
  </code></pre>
  <p><a href="https://i.stack.imgur.com/FV6hT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FV6hT.png" alt="fig3" /></a></p>
  <pre><code>selected_df = df.loc[df[&quot;y&quot;] &lt;=y_line ] #y_line is a list, doesn't work
  </code></pre>
  <p>I also unfortunately must not solve it by filling <code>y_line</code> with more points to make <code>y_line</code> same size as <code>df[&quot;y&quot;]</code>.
  Can anyone please show me the direction how to select the bottom points preferably using functions of DataFrame such as <code>df.where</code> or a condition? I would appreciate it very much.</p>