ComenzarEmpieza gratis

Calculating weekly rental totals

Beyond filtering, you often need to aggregate data by time periods. To spot trends across July and compare week-over-week demand, calculate weekly rental totals.

polars is loaded as pl. The DataFrame bikes is available, sorted by time.

Este ejercicio forma parte del curso

Data Transformation with Polars

Ver curso

Instrucciones del ejercicio

  • Group the data by week using group_by_dynamic().
  • Calculate the sum of rentals and name it total_rentals.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Group the data by week
bikes.____("time", every="____").agg(
  
    # Calculate the sum of rentals
    pl.col("rentals").____().alias("____")
)
Editar y ejecutar código