title: pyspark window function with filter
body: <p>I have the following DataFrame with columns: <code>["id", "timestamp", "x", "y"]</code>:</p>
  
  <pre class="lang-python prettyprint-override"><code>+---+----------+---+---+
  | id| timestamp|  x|  y|
  +---+----------+---+---+
  |  0|1443489380|100|  1|
  |  0|1443489390|200|  0|
  |  0|1443489400|300|  0|
  |  1|1443489410|400|  1|
  |  1|1443489550|100|  1|
  |  2|1443489560|600|  0|
  |  2|1443489570|200|  0|
  |  2|1443489580|700|  1|
  +---+----------+---+---+
  </code></pre>
  
  <p>I have defined the following <code>Window</code>:</p>
  
  <pre class="lang-python prettyprint-override"><code>from pyspark.sql import Window
  w = Window.partitionBy("id").orderBy("timestamp")
  </code></pre>
  
  <p>I would like to extract only the first and last row of data in the window <code>w</code>. How can I accomplish this?</p>