title: Problem using 'window' function to group by day in PySpark
body: <p>I have a dataset that needs to be resampled. To do so, I'll need to group it by day and at the same time, calculate the median value of each sensor. I'm using the <code>window</code> function, but, it's only returning one sample.</p>
  
  <p>Here is the dataset:</p>
  
  <pre><code>+--------+-------------+-------------------+------+------------------+
  |Variable|  Sensor Name|          Timestamp| Units|             Value|
  +--------+-------------+-------------------+------+------------------+
  |     NO2|aq_monitor914|2018-10-07 23:15:00|ugm -3|0.9945200000000001|
  |     NO2|aq_monitor914|2018-10-07 23:30:00|ugm -3|1.1449200000000002|
  |     NO2|aq_monitor914|2018-10-07 23:45:00|ugm -3|           1.13176|
  |     NO2|aq_monitor914|2018-10-08 00:00:00|ugm -3|            0.9212|
  |     NO2|aq_monitor914|2018-10-08 00:15:00|ugm -3|           1.39872|
  |     NO2|aq_monitor914|2018-10-08 00:30:00|ugm -3|           1.51528|
  |     NO2|aq_monitor914|2018-10-08 00:45:00|ugm -3|           1.61116|
  |     NO2|aq_monitor914|2018-10-08 01:00:00|ugm -3|           1.59612|
  |     NO2|aq_monitor914|2018-10-08 01:15:00|ugm -3|           1.12612|
  |     NO2|aq_monitor914|2018-10-08 01:30:00|ugm -3|           1.04528|
  +--------+-------------+-------------------+------+------------------+
  </code></pre>
  
  <p>And I need to resample it by day, calculating the median of the column "Value" for each day. I'm using the following code to do so:</p>
  
  <pre><code>magic_percentile = psf.expr('percentile_approx(Value, 0.5)') #Calculates median of the 'Value' column 
  
  data = data.groupby('Variable','Sensor Name',window('Timestamp', "1 day")).agg(magic_percentile.alias('Value')
  </code></pre>
  
  <p>But, here is the problem, this is only returning me the following DataFrame:</p>
  
  <pre><code>+--------+-------------+--------------------+-------+
  |Variable|  Sensor Name|              window|  Value|
  +--------+-------------+--------------------+-------+
  |     NO2|aq_monitor914|[2018-10-07 21:00...|1.13176|
  +--------+-------------+--------------------+-------+
  </code></pre>
  
  <p>Detailing the 'window' column:</p>
  
  <pre><code>window=Row(start=datetime.datetime(2018, 10, 7, 21, 0), end=datetime.datetime(2018, 10, 8, 21, 0))
  </code></pre>
  
  <p>In my understanding of the <code>window</code>, it should make a one day window for the current timestamp, for example:
  <code>2018-10-07 23:15:00</code>
  should become:
  <code>2018-10-07</code>
  and group the sensors by the Variable, Sensor Name, and the current day, then, calculate it's median. I'm really confuse on how to do this.</p>