开始使用免费开始使用

Filtering for a time range

Now that you can filter for a single moment, let's filter for a range. To understand the morning commute pattern, find all rows between 7 AM and 10 AM on the first day to analyze the morning rush.

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

本练习是课程的一部分

Data Transformation with Polars

查看课程

练习说明

  • Filter bikes for rows where time is between 7 AM and 10 AM on July 1st, 2016.

交互式实操练习

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

# Filter for morning rush hour (7 AM - 10 AM)
bikes.filter(
    pl.col("time").____(
        pl.datetime(2016, 7, 1, ____),
        pl.datetime(2016, 7, 1, ____)
    )
)
编辑并运行代码