title: Best practices for indexing with pandas
body: <p>I want to select rows based on a mask, <code>idx</code>. I can think of two different possibilities, either using <code>iloc</code> or just using brackets. I have shown the two possibilities (on a dataframe <code>df</code>) below. Are they both equally viable?</p>
  
  <pre><code>idx = (df["timestamp"] &gt;= 5) &amp; (df["timestamp"] &lt;= 10)
  idx = idx.values
  hr = df["hr"].iloc[idx]
  timestamps = df["timestamp"].iloc[idx]
  </code></pre>
  
  <p>or the following one:</p>
  
  <pre><code>idx = (df["timestamp"] &gt;= 5) &amp; (df["timestamp"] &lt;= 10)
  hr = df["hr"][idx]
  timestamps = df["timestamp"][idx]
  </code></pre>