The time_series
module extends pandas
functionality
for manipulating time series data. It is intended support tasks particular to
dealing with atmospheric / weather data.
As an example, we create a pandas.Series
object with missing data and
fill in the missing data using the periodic_interpolation
method.
>>> import numpy as np
>>> import pandas as pd
>>> # Create a Series with missing data
>>> demo_series = pd.Series(np.arange(10, 21))
>>> demo_series.iloc[[0, -1]] = np.nan
>>> print(demo_series)
0 NaN
1 11.0
2 12.0
3 13.0
4 14.0
5 15.0
6 16.0
7 17.0
8 18.0
9 19.0
10 NaN
dtype: float64
>>> # Interpolate for the missing data using periodic boundary conditions
>>> print(demo_series.tsu.periodic_interpolation())
0 13.666667
1 11.000000
2 12.000000
3 13.000000
4 14.000000
5 15.000000
6 16.000000
7 17.000000
8 18.000000
9 19.000000
10 16.333333
dtype: float64
For information on what other methods are incorporated under the tsu
accessor attribut, see the TSUAccessor
class.
Calculate number of seconds elapsed modulo 1 year.
Accurate to within a microsecond.
date (Union
[datetime
, Collection
[datetime
]]) – Date(s) to calculate seconds for
Union
[float
, float16
, float32
, float64
, float128
, int
, int8
, int16
, int32
, int64
, uint8
, uint16
, uint32
, uint64
, longlong
, ulonglong
, ndarray
]
A single float if the input is a single datetime, or a numpy array if the input is a collection.
Pandas Series accessor for time series utilities
Extends pandas
support for time series data
DO NOT USE THIS CLASS DIRECTLY! This class is registered as a pandas accessor. See the module level usage example for more information.
Return the supplemented subset of the series corresponding to a given year
Data for the given year is supplemented with any available data from
supplementary years by asserting that the measured values from
supplementary years are exactly the same as they would be if taken during
the primary year. Priority is given to supplementary years in the order
specified by the supp_years
argument.
year (int
) – Year to supplement data for
supp_years (Collection
[int
]) – Years to supplement data with when missing from year
Series
A pandas Series object
Linearly interpolate the series using periodic boundary conditions
Similar to the default linear interpolation used by pandas, but missing values at the beginning and end of the series are interpolated assuming a periodic boundary condition.
Series
An interpolated copy of the passed series