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.
Questo esercizio fa parte del corso
Data Transformation with Polars
Istruzioni dell'esercizio
- Group the data by week using
group_by_dynamic(). - Calculate the sum of
rentalsand name ittotal_rentals.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Group the data by week
bikes.____("time", every="____").agg(
# Calculate the sum of rentals
pl.col("rentals").____().alias("____")
)