pub struct DataFrame {
pub columns: HashMap<String, Vec<f64>>,
pub timestamps: Vec<i64>,
pub id: String,
pub timeframe: Timeframe,
}Expand description
Generic columnar storage for time series data
Stores data as named columns of f64 values, plus timestamps. No knowledge of specific column names (open, high, low, close, etc.) is encoded here - that’s determined by the data source.
Fields§
§columns: HashMap<String, Vec<f64>>Column name -> column data
timestamps: Vec<i64>Timestamps (always present, Unix seconds)
id: StringGeneric identifier
timeframe: TimeframeTimeframe of the data
Implementations§
Source§impl DataFrame
impl DataFrame
Sourcepub fn with_capacity(id: &str, timeframe: Timeframe, capacity: usize) -> Self
pub fn with_capacity(id: &str, timeframe: Timeframe, capacity: usize) -> Self
Create a DataFrame with pre-allocated capacity
Sourcepub fn from_rows(
id: &str,
timeframe: Timeframe,
rows: Vec<OwnedDataRow>,
) -> Self
pub fn from_rows( id: &str, timeframe: Timeframe, rows: Vec<OwnedDataRow>, ) -> Self
Create from a list of rows
Sourcepub fn add_column(&mut self, name: &str, data: Vec<f64>)
pub fn add_column(&mut self, name: &str, data: Vec<f64>)
Add a column of data
Sourcepub fn get_column(&self, name: &str) -> Option<&[f64]>
pub fn get_column(&self, name: &str) -> Option<&[f64]>
Get a column by name
Sourcepub fn get_column_mut(&mut self, name: &str) -> Option<&mut Vec<f64>>
pub fn get_column_mut(&mut self, name: &str) -> Option<&mut Vec<f64>>
Get a mutable column by name
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Get the number of columns
Sourcepub fn column_names(&self) -> impl Iterator<Item = &str>
pub fn column_names(&self) -> impl Iterator<Item = &str>
Get column names
Sourcepub fn has_column(&self, name: &str) -> bool
pub fn has_column(&self, name: &str) -> bool
Check if a column exists
Sourcepub fn get_timestamp(&self, index: usize) -> Option<i64>
pub fn get_timestamp(&self, index: usize) -> Option<i64>
Get timestamp at index
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataFrame
impl RefUnwindSafe for DataFrame
impl Send for DataFrame
impl Sync for DataFrame
impl Unpin for DataFrame
impl UnsafeUnpin for DataFrame
impl UnwindSafe for DataFrame
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more