From the course: Data Analysis with Python and Pandas
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Date and time parts
From the course: Data Analysis with Python and Pandas
Date and time parts
- [Instructor] So as we just saw, we can extract datetime components as a string using the string format time method. Generally speaking, what we want to do when we want to extract time parts, is use the dedicated datetime accessors. So we've seen several examples of this throughout the course. A lot of these times the values within our datetime service, create anchors for aggregation and just help us get more layers to an analysis. And so if you want to extract just the date portion of the date time, we just need to specify dates.DT.date. This will return the date portion of our date as an object. To return the year, we can specify dates.DT.year. Note this returns in integer. Our month also returns in integer. So we have dates.DT.month. And finally, we could also return things like the day of week. A lot of the times our day of week, you know, Monday, Tuesday, Wednesday, is going to be a more interesting layer for analysis than the calendar day of week. And so what we're about to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Times in Python and pandas3m 8s
-
(Locked)
Converting to datetimes6m 16s
-
(Locked)
Formatting dates5m 20s
-
(Locked)
Date and time parts3m 4s
-
(Locked)
Challenge: pandas datetime basics1m 23s
-
(Locked)
Solution: pandas datetime basics2m 10s
-
(Locked)
Time deltas and arithmetic6m 54s
-
(Locked)
Challenge: Time deltas1m 10s
-
(Locked)
Solution: Time deltas1m 29s
-
(Locked)
Time series indices3m 58s
-
(Locked)
Missing time series data4m 45s
-
(Locked)
Challenge: Missing time series data1m 44s
-
(Locked)
Solution: Missing time series data2m 13s
-
(Locked)
Shifting time series3m 16s
-
(Locked)
Pro tip: diff()2m 54s
-
(Locked)
Challenge: shift() and diff()1m 39s
-
(Locked)
Solution: shift() and diff()2m 47s
-
(Locked)
Aggregation and resampling4m 6s
-
(Locked)
Challenge: Resampling41s
-
(Locked)
Solution: Resampling1m 53s
-
(Locked)
Rolling aggregations4m 35s
-
(Locked)
Challenge: Rolling aggregations45s
-
(Locked)
Solution: Rolling aggregations55s
-
(Locked)
Key takeaways1m 37s
-
(Locked)
-
-
-