Time Series Indexes—Methods
Learn about the common methods and operations that come with time series indexes for manipulating and analyzing time series data.
Introduction
Having covered the attributes that come with time series index objects, we’ll now look at the essential methods and operations for time series data manipulation. In particular, we’ll explore the techniques that go beyond the indexing and slicing tasks already seen in the earlier lessons.
Understanding the common methods and operations that come with time series indexes is crucial for effectively manipulating and analyzing time-series data. As before, we’ll focus on the DatetimeIndex object given its common usage and ideal representation of time series indexes.
We’ll use the New Delhi daily climate time series dataset for the examples in this lesson.
Preview of New Delhi Daily Climate Time Series Data
Date | meantemp | humidity | wind_speed | meanpressure |
1/1/2017 | 15.91304348 | 85.86956522 | 2.743478261 | 59 |
2/1/2017 | 18.5 | 77.22222222 | 2.894444444 | 1018.277778 |
3/1/2017 | 17.11111111 | 81.88888889 | 4.016666667 | 1018.333333 |
4/1/2017 | 18.7 | 70.05 | 4.545 | 1015.7 |
5/1/2017 | 18.38888889 | 74.94444444 | 3.3 | 1014.333333 |
Basic filtering
We can apply filters to the attributes of the DatetimeIndex we’ve seen previously. For example, we can use the standard square bracket syntax to filter the New Delhi climate data to days that fall on either a Monday (value 0) or Friday (value 4), as shown below:
We can apply multiple conditions while filtering as well. For example, we can retrieve data for the day that falls on the first quarter’s end.
Frequency rounding
We can apply rounding operations on the time series index to a specified frequency with the following methods: ...