We will now examine several common operations that are performed on time-series data. These operations entail realigning data, changing the frequency of the samples and their values, and calculating aggregate results on continuously moving subsets of the data to determine the behavior of the values in the data as time changes.
Manipulating time-series data
Shifting and lagging
A common operation on time-series data is to shift the values backward and forward in time. The pandas method for this is .shift() which will shift values in a Series or DataFrame a specified number of units of the frequency in the index.
To demonstrate shifting, we will use the following Series. This Series has five values, is indexed by date starting...