開始使用免費開始

每個平日花多久?

Pandas 在 .dt 存取器中提供多個與日期時間相關的屬性。很多你之前已經用過,例如 .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())
編輯並執行程式碼