title: Group days into weeks with totals PySpark
body: <p>I recently had help with a similar query <a href="https://stackoverflow.com/questions/57347965/date-add-or-date-diff-error-when-grouping-dates-in-bigquery/57348769?noredirect=1#comment101185948_57348769">DATE_ADD or DATE_DIFF error when grouping dates in BigQuery</a> but I was wondering how to do this in PySpark as I am rather new</p>
  
  <pre><code>day         bitcoin_total   dash_total
  2009-01-03  1               0
  2009-01-09  14              0
  2009-01-10  61              0
  </code></pre>
  
  <p>The desirable outcome would be the date at the start of the week (could be Monday or Sunday, whichever) </p>
  
  <pre><code>day         bitcoin_total   dash_total
  2008-12-28  1               0
  2009-01-04  75              0
  </code></pre>
  
  <p>The below code is returning weeks by numbers and the totals seems off. I cannot seem to replicate the total that .agg(sum()) is returning and I cannot even add the second total (dash_total). I tried <code>.col("dash_total")</code> Is there a way to group days into weeks? </p>
  
  <pre><code>from pyspark.sql.functions import weekofyear, sum
  
  (df
      .groupBy(weekofyear("day").alias("date_by_week"))
      .agg(sum("bitcoin_total"))
      .orderBy("date_by_week")
      .show())
  </code></pre>
  
  <p>I am running Spark on Databricks.</p>