开始使用免费开始使用

每个工作日用时多长?

.dt 访问器下,pandas 提供了许多与日期时间相关的属性。很多您已经见过,比如 .dt.month。还有一些更方便的功能,相比标准 Python 能节省时间,例如 .dt.day_name()

本练习是课程的一部分

在 Python 中处理日期和时间

查看课程

练习说明

  • rides 中新增一列 'Ride start weekday',其值为 Start date 的星期几。
  • 打印每个星期几的骑行时长中位数。

交互式实操练习

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

# Add a column for the weekday of the start of the ride
rides['Ride start weekday'] = rides['Start date'].____

# Print the median trip time per weekday
print(rides.____(____)['Duration'].median())
编辑并运行代码