title: Pandas data frame and SQL query
body: <p>I'm trying to translate the SQL query to pandas. However, after trying a lot I have now a knot in my head...</p>
  
  <pre><code>SELECT
   ID, Date1, Date2, Value
  FROM
   data t1
  WHERE
   t1.ID = 100 AND Date2 BETWEEN '2010-01-01 00:00:00.0' AND '2010-01-31 23:59:59.0' AND t1.Date1 =
   (
    SELECT
     max(t2.Date1)
    FROM
     data t2
    WHERE
     t2.Date1 &lt;= '2010-02-01 00:00:00.0' AND t2.ID = t1.ID AND t2.Date2 = t1.Date2
   ) 
  ORDER BY
   t1.Date2
  </code></pre>
  
  <p>Does anyone have a clever idea?</p>
  
  <p>Many Thanks</p>