Times and Dates in Pandas
summary
Pandas code converts CSV strings to real datetimes with pd.to_datetime and read_csv(parse_dates=...), shrinking NYC taxi timestamps from ~977 MB as strings to ~250 MB (about 75% less memory). The dt accessor extracts hour/day/month, enabling groupby by hour, value_counts (New Year’s mean trip distance ≈ 3.5 miles), and creating timedeltas by subtracting dropoff − pickup (total_seconds usable, only days/seconds/microseconds stored). Time zones use tz_localize and tz_convert, grouper and resample support chronological bins, and unexpected early 2003 rows can produce NaNs that need dropna.
AI-written summary · about
chapters (16)
- 0:00Dates and times in pandas
- 1:47Datetime vs TimeDelta objects
- 3:53Reading CSV with datetime
- 7:45Invalid dates with to_datetime
- 8:49Ambiguous date formats
- 10:53Basic datetime operations
- 12:19Sorting and filtering datetimes
- 13:24Extracting datetime components
- 15:14Trip durations with TimeDelta
- 17:26Time zones in pandas
- 19:57Grouping by datetime
- 21:20Pivot tables with datetime
- 22:48Grouping with Grouper
- 25:13Indexing TimeSeries data
- 26:39Resampling TimeSeries
- 27:20Summary of datetime functions
related talks
45mTimes and dates in Pandas
28mWorking with dates and times in Pandas
01h 52mIntroduction to data analytics with pandas
50mDrive-in Double-header: Datetimes and Log analysis
34mNoSQL Python: making data frames work for you in a non-rectangular world
01h 31mPandas, Data Wrangling & Data Science
31mEffective Data Analysis with Pandas Indexes
26mHandling Timezones in Python
