mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:00:01 +00:00
Enhance documentation with usage examples for core data-frame structures and operations
This commit is contained in:
parent
676f78bb1e
commit
d1dd7ea6d2
@ -1,3 +1,19 @@
|
|||||||
|
//! Core data-frame structures such as [`Frame`] and [`RowIndex`].
|
||||||
|
//!
|
||||||
|
//! The [`Frame`] type stores column-labelled data with an optional row index
|
||||||
|
//! and builds upon the [`crate::matrix::Matrix`] type.
|
||||||
|
//!
|
||||||
|
//! # Examples
|
||||||
|
//!
|
||||||
|
//! ```
|
||||||
|
//! use rustframe::frame::{Frame, RowIndex};
|
||||||
|
//! use rustframe::matrix::Matrix;
|
||||||
|
//!
|
||||||
|
//! let data = Matrix::from_cols(vec![vec![1, 2], vec![3, 4]]);
|
||||||
|
//! let frame = Frame::new(data, vec!["L", "R"], Some(RowIndex::Int(vec![10, 20])));
|
||||||
|
//! assert_eq!(frame.columns(), &["L", "R"]);
|
||||||
|
//! assert_eq!(frame.index(), &RowIndex::Int(vec![10, 20]));
|
||||||
|
//! ```
|
||||||
use crate::matrix::Matrix;
|
use crate::matrix::Matrix;
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
//! High-level interface for working with columnar data and row indices.
|
||||||
|
//!
|
||||||
|
//! The [`Frame`](crate::frame::Frame) type combines a matrix with column labels and a typed row
|
||||||
|
//! index, similar to data frames in other data-analysis libraries.
|
||||||
|
//!
|
||||||
|
//! # Examples
|
||||||
|
//!
|
||||||
|
//! ```
|
||||||
|
//! use rustframe::frame::{Frame, RowIndex};
|
||||||
|
//! use rustframe::matrix::Matrix;
|
||||||
|
//!
|
||||||
|
//! // Build a frame from two columns labelled "A" and "B".
|
||||||
|
//! let data = Matrix::from_cols(vec![vec![1.0, 2.0], vec![3.0, 4.0]]);
|
||||||
|
//! let frame = Frame::new(data, vec!["A", "B"], None);
|
||||||
|
//!
|
||||||
|
//! assert_eq!(frame["A"], vec![1.0, 2.0]);
|
||||||
|
//! assert_eq!(frame.index(), &RowIndex::Range(0..2));
|
||||||
|
//! ```
|
||||||
pub mod base;
|
pub mod base;
|
||||||
pub mod ops;
|
pub mod ops;
|
||||||
|
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
//! Trait implementations that allow [`Frame`] to reuse matrix operations.
|
||||||
|
//!
|
||||||
|
//! These modules forward numeric and boolean aggregation methods from the
|
||||||
|
//! underlying [`Matrix`](crate::matrix::Matrix) type so that they can be called
|
||||||
|
//! directly on a [`Frame`].
|
||||||
|
//!
|
||||||
|
//! ```
|
||||||
|
//! use rustframe::frame::Frame;
|
||||||
|
//! use rustframe::matrix::{Matrix, SeriesOps};
|
||||||
|
//!
|
||||||
|
//! let frame = Frame::new(Matrix::from_cols(vec![vec![1.0, 2.0]]), vec!["A"], None);
|
||||||
|
//! assert_eq!(frame.sum_vertical(), vec![3.0]);
|
||||||
|
//! ```
|
||||||
use crate::frame::Frame;
|
use crate::frame::Frame;
|
||||||
use crate::matrix::{Axis, BoolMatrix, BoolOps, FloatMatrix, SeriesOps};
|
use crate::matrix::{Axis, BoolMatrix, BoolOps, FloatMatrix, SeriesOps};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user