ComeçarComece de graça

Extracting the hour component

With the datetime properly parsed, you want to identify when bike demand peaks during the day. To compare rentals across different hours, you need to extract the hour component from each timestamp.

polars is loaded as pl. The DataFrame bikes is available with the time column already parsed as a Datetime.

Este exercício faz parte do curso

Data Transformation with Polars

Ver curso

Instruções do exercício

  • Extract the hour from the time column and name the new column hour.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Extract the hour from the time column
bikes.with_columns(
    pl.col("time").____.____().____("hour")
)
Editar e executar o código