pub struct TimeSeries {
pub name: String,
pub timestamps: Vec<i64>,
pub values: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub frequency: Option<Frequency>,
pub metadata: HashMap<String, String>,
}Expand description
Time series data structure
Fields§
§name: StringSeries name
timestamps: Vec<i64>Time index (Unix timestamps in seconds)
values: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>Values
frequency: Option<Frequency>Frequency (if regular)
metadata: HashMap<String, String>Metadata
Implementations§
Source§impl TimeSeries
impl TimeSeries
Sourcepub fn new(
name: impl Into<String>,
timestamps: Vec<i64>,
values: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
frequency: Option<Frequency>,
) -> Result<TimeSeries, Error>
pub fn new( name: impl Into<String>, timestamps: Vec<i64>, values: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, frequency: Option<Frequency>, ) -> Result<TimeSeries, Error>
Create a new time series from arrays
Sourcepub fn from_dataframe(
df: &DataFrame,
value_col: &str,
date_col: &str,
) -> Result<TimeSeries, Error>
pub fn from_dataframe( df: &DataFrame, value_col: &str, date_col: &str, ) -> Result<TimeSeries, Error>
Create from DataFrame with date and value columns
Sourcepub fn regular(
name: impl Into<String>,
values: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
frequency: Frequency,
) -> TimeSeries
pub fn regular( name: impl Into<String>, values: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, frequency: Frequency, ) -> TimeSeries
Create a regular time series with integer index
Sourcepub fn timestamps(&self) -> &[i64]
pub fn timestamps(&self) -> &[i64]
Get timestamps
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get metadata
Sourcepub fn start_time(&self) -> Option<i64>
pub fn start_time(&self) -> Option<i64>
Get start time
Sourcepub fn stats(&self) -> TimeSeriesStats
pub fn stats(&self) -> TimeSeriesStats
Compute basic statistics
Sourcepub fn diff(&self, lag: usize, order: usize) -> Result<TimeSeries, Error>
pub fn diff(&self, lag: usize, order: usize) -> Result<TimeSeries, Error>
Differencing: y_t - y_{t-d}
Sourcepub fn log(&self, offset: f64) -> TimeSeries
pub fn log(&self, offset: f64) -> TimeSeries
Log transformation (with offset to handle zeros/negatives)
Sourcepub fn boxcox(&self, lambda: f64) -> TimeSeries
pub fn boxcox(&self, lambda: f64) -> TimeSeries
Box-Cox transformation
Sourcepub fn slice(
&self,
start: Option<i64>,
end: Option<i64>,
) -> Result<TimeSeries, Error>
pub fn slice( &self, start: Option<i64>, end: Option<i64>, ) -> Result<TimeSeries, Error>
Slice time series
Sourcepub fn fillna(&self, method: FillMethod) -> TimeSeries
pub fn fillna(&self, method: FillMethod) -> TimeSeries
Fill missing values (NaN) using specified method
Sourcepub fn detect_outliers(&self, threshold: f64) -> Vec<usize>
pub fn detect_outliers(&self, threshold: f64) -> Vec<usize>
Detect outliers using IQR method
Sourcepub fn to_dataframe(&self) -> DataFrame
pub fn to_dataframe(&self) -> DataFrame
Convert to DataFrame
Trait Implementations§
Source§impl ARIMAExt for TimeSeries
impl ARIMAExt for TimeSeries
Source§impl Clone for TimeSeries
impl Clone for TimeSeries
Source§fn clone(&self) -> TimeSeries
fn clone(&self) -> TimeSeries
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TimeSeries
impl Debug for TimeSeries
Source§impl DecompositionExt for TimeSeries
impl DecompositionExt for TimeSeries
Source§fn decompose_ma(
&self,
method: DecompositionMethod,
period: usize,
) -> Result<DecompositionResults, Error>
fn decompose_ma( &self, method: DecompositionMethod, period: usize, ) -> Result<DecompositionResults, Error>
Moving average decomposition
Source§fn decompose_stl(&self, period: usize) -> Result<DecompositionResults, Error>
fn decompose_stl(&self, period: usize) -> Result<DecompositionResults, Error>
STL decomposition
Source§fn hp_filter(&self, lambda: f64) -> Result<(TimeSeries, TimeSeries), Error>
fn hp_filter(&self, lambda: f64) -> Result<(TimeSeries, TimeSeries), Error>
Hodrick-Prescott filter
Source§fn x12_adjust(&self, period: usize) -> Result<TimeSeries, Error>
fn x12_adjust(&self, period: usize) -> Result<TimeSeries, Error>
X-12-ARIMA seasonal adjustment
Source§impl<'de> Deserialize<'de> for TimeSeries
impl<'de> Deserialize<'de> for TimeSeries
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TimeSeries, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TimeSeries, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl GARCHExt for TimeSeries
impl GARCHExt for TimeSeries
Source§impl Serialize for TimeSeries
impl Serialize for TimeSeries
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for TimeSeries
impl RefUnwindSafe for TimeSeries
impl Send for TimeSeries
impl Sync for TimeSeries
impl Unpin for TimeSeries
impl UnsafeUnpin for TimeSeries
impl UnwindSafe for TimeSeries
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.