开始使用免费开始使用

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.

本练习是课程的一部分

Data Transformation with Polars

查看课程

练习说明

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

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Extract the hour from the time column
bikes.with_columns(
    pl.col("time").____.____().____("hour")
)
编辑并运行代码