在 Pandas 載入 CSV 檔案
capital_onebike.csv 檔案包含 Capital Bikeshare 腳踏車 W20529 在 10 月、11 月和 12 月的騎乘紀錄。
以下是前兩個欄位:
| Start date | End date | ... |
|---|---|---|
| 2017-10-01 15:23:25 | 2017-10-01 15:26:26 | ... |
| 2017-10-01 15:42:57 | 2017-10-01 17:49:59 | ... |
本練習屬於課程
在 Python 處理日期與時間
練習說明
- 匯入 Pandas。
- 完成對
read_csv()的呼叫,正確解析Start date和End date這兩個日期欄位。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import pandas
import ____ as pd
# Load CSV into the rides variable
rides = pd.read_csv('capital-onebike.csv',
parse_dates = ____)
# Print the initial (0th) row
print(rides.iloc[0])