Skip to main content

DataFrame

Struct DataFrame 

Source
pub struct DataFrame {
    pub constants: HashMap<Key, DataValue>,
    pub dataframe: ColumnFrame,
    pub metadata: HashMap<String, DataValue>,
}
Expand description

User-facing dataframe: a ColumnFrame with attached constants and metadata.

§Storage

The underlying ColumnFrame is column-oriented — each column lives in its own crate::TypedData variant. Materialize a 2-D view with DataFrame::select (row-major) or DataFrame::select_view (zero-copy where possible).

§Example

use trs_dataframe::{DataFrame, column_frame};

let df = DataFrame::new(column_frame! {
    "a" => [1, 2, 3],
    "b" => [4, 5, 6]
});

// Materialize all columns as a row-major 2-D array (rows × columns).
let all_data = df.select(None);

// Materialize a specific subset of columns.
let keys = vec!["a".into(), "b".into()];
let selected = df.select(Some(&keys));

Fields§

§constants: HashMap<Key, DataValue>

Whole-frame constants — values that logically apply to every row but are not stored per-row. Useful for shared metadata that joins should preserve. They do not appear in select results.

§dataframe: ColumnFrame

Column-oriented storage backing this dataframe.

§metadata: HashMap<String, DataValue>

Free-form user metadata. Does not participate in any data operation.

Implementations§

Source§

impl DataFrame

Source

pub fn init() -> Self

Create a new empty DataFrame.

Source

pub fn from_dict(df: HashMap<String, Vec<DataValue>>) -> Self

Create a DataFrame from a dictionary.

df = tdf.DataFrame.from_dict({"a": [1, 2, 3], "b": [4, 5, 6]})
Source

pub fn keys(&self) -> Vec<Key>

Returns the keys of the DataFrame.

Source

pub fn set_dtype_for_column( &mut self, key: String, dtype: DataType, ) -> PyResult<()>

Convert the DataFrame to polars DataFrame.

df = tdf.DataFrame.from_dict({"a": [1, 2, 3], "b": [4, 5, 6]});
df.set_dtype_for_column("a", trs.DataType.I32)
Source

pub fn apply(&mut self, function: Bound<'_, PyAny>) -> Result<(), PyErr>

Apply a function to the DataFrame. The function should accept a DataFrame and return a DataFrame.

def my_function(df):
   # Perform some operations on the DataFrame
  return df
/// df = tdf.DataFrame.init()
df.apply(my_function)
Source

pub fn as_numpy_u32<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<u32>>>

Returns slice from dataframe as numpy.array of uint32 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
a_np = df.as_numpy_u32(['key1', 'key2'])
assert np.array_equal(a_np, np.array([[1, 11], [2, 21]], dtype=np.uint32))
Source

pub fn as_numpy_u64<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<u64>>>

Returns slice from dataframe as numpy.array of uint64 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
a_np = df.as_numpy_u64(['key1', 'key2'])
assert np.array_equal(a_np, np.array([[1, 11], [2, 21]], dtype=np.uint64))
Source

pub fn as_numpy_i32<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<i32>>>

Returns slice from dataframe as numpy.array of int32 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
a_np = df.as_numpy_i32(['key1', 'key2'])
assert np.array_equal(a_np, np.array([[1, 11], [2, 21]], dtype=np.int32))
Source

pub fn as_numpy_i64<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<i64>>>

Returns slice from dataframe as numpy.array of int64 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
a_np = df.as_numpy_i64(['key1', 'key2'])
assert np.array_equal(a_np, np.array([[1, 11], [2, 21]], dtype=np.int64))
Source

pub fn as_numpy_f32<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<f32>>>

Returns slice from dataframe as numpy.array of float32 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
a_np = df.as_numpy_f32(['key1', 'key2'])
assert np.array_equal(a_np, np.array([[1, 11], [2, 21]], dtype=np.float32))
Source

pub fn as_numpy_f64<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<f64>>>

Returns slice from dataframe as numpy.array of float64 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
a_np = df.as_numpy_f64(['key1', 'key2'])
assert np.array_equal(a_np, np.array([[1, 11], [2, 21]], dtype=np.float64))
Source

pub fn as_numpy_str<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<Py<PyAny>>>>

Returns slice from dataframe as numpy.array of objects of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": "a", "key2": "b"})
df.push({"key1": "d", "key2": "c"})
a_np = df.as_numpy_f64(['key1', 'key2'])
assert np.array_equal(a_np, np.array([["a", d""], ["b", "c"]], dtype=np.object))
Source

pub fn as_numpy<'py>( &self, keys: Option<Vec<String>>, transposed: Option<bool>, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray2<Py<PyAny>>>>

Returns slice from dataframe as numpy.array of float64 of the given keys. If transposed is true, the keys will be transposed. If keys is None, all keys will be used.

import numpy as np
df = tdf.DataFrame.init()
df.push({"key1": "a", "key2": 1})
df.push({"key1": "d", "key2": 2})
a_np = df.as_numpy_f64(['key1', 'key2'])
assert np.array_equal(a_np, np.array([["a", d""], [1, 2]], dtype=np.object))
Source

pub fn py_shrink(&mut self)

Source

pub fn py_add_metadata(&mut self, key: String, value: DataValue)

Source

pub fn py_get_metadata(&self, key: &str) -> Option<DataValue>

Source

pub fn py_rename_key(&mut self, key: &str, new_name: &str) -> Result<(), PyErr>

Source

pub fn py_add_alias(&mut self, key: &str, new_name: &str) -> Result<(), PyErr>

Source

pub fn py_select<'py>( &self, py: Python<'py>, keys: Option<Vec<String>>, transposed: Option<bool>, ) -> Result<Bound<'py, PyList>, PyErr>

Selects data from the DataFrame. If keys is None, all keys will be used. If keys is provided, only the specified keys will be selected. Returns a list of lists, where each inner list represents a row of data.

import trs_dataframe as tdf
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
# selected = df.select(["key1", "key2"])
# assert selected == [[1, 2], [11, 21]]
# selected = df.select()
Source

pub fn py_select_column<'py>( &self, py: Python<'py>, key: String, ) -> Result<Bound<'py, PyList>, PyErr>

Selects a column from the DataFrame. If the column does not exist, it will raise a TypeError. Returns a list of values in the selected column.

import trs_dataframe as tdf
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
# selected = df.select_column("key1")
# assert selected == [1, 11]
# selected = df.select_column("key2")
# assert selected == [2, 21]
# selected = df.select_column("non_existing_key")  # Raises TypeError
Source

pub fn py_join( &mut self, other: DataFrame, join_type: JoinRelation, ) -> Result<(), PyErr>

Joins the current DataFrame with another DataFrame. The join type is specified by the join_type parameter. see JoinRelation for available join types.

import trs_dataframe as tdf
df1 = tdf.DataFrame.init()
df1.push({"key1": 1, "key2": 2})
df1.push({"key1": 11, "key2": 21})
df2 = tdf.DataFrame.init()
df2.push({"key1": 1, "key2": 3})
df2.push({"key1": 11, "key2": 23})
df1.join(df2, tei.JoinRelation.extend())
assert df1.select(["key1", "key2"]) == [[1, 2], [11, 21], [1, 3], [11, 23]]
Source

pub fn py_push(&mut self, data: HashMap<Key, DataValue>) -> Result<(), PyErr>

Pushes a new row of data into the DataFrame. The data should be provided as a dictionary where keys are column names and values are the corresponding data values.

import trs_dataframe as tdf
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
Source

pub fn py_add_column( &mut self, key: Key, data: Vec<DataValue>, ) -> Result<(), PyErr>

Adds a new column to the DataFrame. The column is specified by a key and a vector of data values. If the length of the data vector does not match the number of rows in the DataFrame, it will raise a TypeError.

import trs_dataframe as tdf
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
df.add_column("key3", [3, 4])
assert df.select(["key1", "key2", "key3"]) == [[1, 2, 3], [11, 21, 4]]
Source

pub fn add_constant( &mut self, key: Key, feature: DataValue, ) -> Result<(), PyErr>

Source

pub fn filter_by_expression( &mut self, expression: String, ) -> Result<Self, PyErr>

Filters the DataFrame by a given expression. The expression should be a string that can be parsed by the DataFrame’s filter method

import trs_dataframe as tdf
df = tdf.DataFrame.init()
df.push({"key1": 1, "key2": 2})
df.push({"key1": 11, "key2": 21})
df.filter_by_expression("key1 > 5")
assert df.select(["key1", "key2"]) == [[11, 21 ]]
Source

pub fn __iadd__(&mut self, object: Bound<'_, PyAny>) -> Result<(), PyErr>

Source

pub fn __isub__(&mut self, object: Bound<'_, PyAny>) -> Result<(), PyErr>

Source

pub fn __imul__(&mut self, object: Bound<'_, PyAny>) -> Result<(), PyErr>

Source

pub fn __itruediv__(&mut self, object: Bound<'_, PyAny>) -> Result<(), PyErr>

Source

pub fn __len__(&mut self) -> Result<usize, PyErr>

Source

pub fn serialize_to_json_string(&self) -> String

Source

pub fn deserialize_from_json_string(json_df: String) -> Self

Source

pub fn __setstate__(&mut self, state: Bound<'_, PyBytes>) -> PyResult<()>

Source

pub fn __getstate__<'py>( &self, py: Python<'py>, ) -> PyResult<Bound<'py, PyBytes>>

Source

pub fn __del__(&mut self)

Source§

impl DataFrame

Source

pub fn new<C: Into<ColumnFrame>>(dataframe: C) -> Self

Creates a new DataFrame from anything that can be converted into a ColumnFrame.

§Examples
use trs_dataframe::{DataFrame, column_frame};

let df = DataFrame::new(column_frame! {
    "a" => [1, 2, 3],
    "b" => [4, 5, 6]
});
assert_eq!(df.n_rows(), 3);
assert_eq!(df.n_columns(), 2);
Source

pub fn n_columns(&self) -> usize

Returns the number of columns which dataframe contains.

Source

pub fn n_rows(&self) -> usize

Returns the number of rows which dataframe contains.

Source

pub fn shrink(&mut self)

Compacts the internal storage to reclaim memory after row deletions or filter operations that may leave excess capacity allocated.

Source

pub fn add_metadata(&mut self, key: String, value: DataValue)

Attaches a key-value metadata entry to this dataframe.

Metadata does not participate in data operations (select, join, filter, etc.) and is intended for user-defined annotations such as source info or timestamps.

Source

pub fn get_metadata(&self, key: &str) -> Option<&DataValue>

Returns a reference to the metadata value for the given key, or None if absent.

Source

pub fn join( &mut self, other: Self, join_type: &JoinRelation, ) -> Result<(), Error>

Joins another dataframe into this one according to the given JoinRelation.

The join strategy is determined by the variant inside join_type:

Constants from other are merged into this dataframe’s constants map.

Source

pub fn apply_function<F>(&mut self, keys: &[Key], func: F) -> Result<(), Error>
where F: FnMut(&[Key], &mut ColumnFrame) -> Result<(), Error>,

Applies a user-defined function to the underlying ColumnFrame.

The closure receives the provided keys and a mutable reference to the internal ColumnFrame, allowing arbitrary in-place transformations.

Source

pub fn select(&self, keys: Option<&[Key]>) -> Result<Array2<DataValue>, Error>

Selects columns and returns their data as a 2D array of DataValue in row-major order.

If keys is None, all columns are returned. If a requested key does not exist, its cells are filled with DataValue::Null.

§Examples
use trs_dataframe::{df, Key};

let df = df! { "a" => [1, 2], "b" => [3, 4] };
let data = df.select(None).unwrap();
assert_eq!(data.nrows(), 2);
Source

pub fn select_typed<T: Extract + Clone>( &self, keys: Option<&[Key]>, ) -> Result<Array2<T>, Error>

Returns selected columns as a typed 2D array, converting each DataValue via the Extract trait.

This is the typed counterpart of select. If keys is None, all columns are returned. The data is in row-major order (rows × columns).

§Type coercion

The Extract trait performs best-effort numeric coercion (e.g. I32 -> f64). Values that cannot be meaningfully converted yield the type’s default (0 for numbers, false for bool, empty string for String).

§Examples
use trs_dataframe::{df, Key};

let df = df! {
    "a" => [1i32, 2i32, 3i32],
    "b" => [4i32, 5i32, 6i32]
};
let keys = vec![Key::from("a"), Key::from("b")];
let arr = df.select_typed::<f64>(Some(&keys)).unwrap();
assert_eq!(arr[[0, 0]], 1.0);
assert_eq!(arr[[1, 1]], 5.0);
Source

pub fn select_view(&self, keys: Option<&[Key]>) -> Result<MaybeView<'_>, Error>

Returns selected columns wrapped in a MaybeView.

View-oriented counterpart of select. The selected columns are stacked into an owned Array2 of shape (ncols, nrows). When keys is None, every column from the underlying crate::KeyIndex is included.

Call MaybeView::row_view on the result to obtain a uniform (nrows, ncols) read-only view regardless of which variant was produced.

§Errors

Returns an error when keys resolves to an empty or entirely unknown key set.

§Examples
use trs_dataframe::{df, Key};

let frame = df! { "a" => [1i32, 2i32], "b" => [3i32, 4i32] };
let keys = vec![Key::from("a"), Key::from("b")];
let view = frame.select_view(Some(&keys)).unwrap();
// row_view() yields a (nrows, ncols) ArrayView2.
assert_eq!(view.row_view().nrows(), 2);
Source

pub fn select_vec_view( &self, keys: Option<&[Key]>, ) -> Result<Vec<Option<&TypedDataArray>>, Error>

Returns selected columns as borrowed crate::TypedData views.

Each entry of the returned Vec corresponds to one requested column, in the same order as keys. Missing keys yield None; present keys yield Some(&TypedData) borrowed directly from the underlying column store — no allocation, no per-element DataValue boxing.

Use crate::TypedData::as_slice_i32 (and friends) for zero-copy access to the native primitive storage, or crate::TypedData::iter for a generic DataValue iterator.

§Errors

Returns an error when keys resolves to an empty or entirely unknown key set.

§Examples
use trs_dataframe::{df, Key};

let frame = df! {
    "score" => [1i32, 2i32, 3i32],
    "rank"  => [10i32, 20i32, 30i32]
};
let cols = frame.select_vec_view(Some(&["score".into()])).unwrap();
assert_eq!(cols.len(), 1);
assert_eq!(cols[0].as_ref().unwrap().len(), 3);
Source

pub fn select_transposed_typed<D: Extract>(&self, keys: &[Key]) -> Vec<Vec<D>>

Returns the requested columns as Vec<Vec<D>> in row-major order — outer Vec is rows, inner Vec is one cell per selected key, with each cell coerced to D via Extract.

Despite the name, the result is not transposed.

Source

pub fn select_column(&self, key: Key) -> Option<Array1<DataValue>>

👎Deprecated:

allocates O(n); use get_column() for zero-copy typed access

Returns a single column materialized as an owned Array1<DataValue>, or None if the key is absent.

Typed columns allocate a DataValue per element on the fly. For zero-copy typed access, use Self::get_column.

Source

pub fn select_transposed( &self, keys: Option<&[Key]>, ) -> Result<Array2<DataValue>, Error>

Stacks the selected columns into an Array2 of shape (ncols, nrows) — each row of the output is one column from the dataframe.

If keys is None, all columns are included.

Source

pub fn insert_constant(&mut self, key: Key, value: DataValue)

Stores a constant value that logically applies to every row without being physically stored per-row.

Constants are carried through joins but do not appear in select results.

Source

pub fn push<C: CandidateData>(&mut self, item: C) -> Result<(), Error>

Appends a single row to the dataframe.

The row is supplied as any type implementing CandidateData (e.g. HashMap<Key, DataValue>). New columns are added automatically if the row contains keys not yet present in the frame.

Source

pub fn remove_column(&mut self, keys: &[Key]) -> Result<Self, Error>

Removes the specified columns from this dataframe and returns them as a new DataFrame.

Source

pub fn extend(&mut self, items: Self) -> Result<(), Error>

Appends all rows from items to this dataframe.

If the two frames have different column sets, missing columns are filled with DataValue::Null.

Source

pub fn len(&self) -> usize

Returns the number of rows in the dataframe.

Source

pub fn is_empty(&self) -> bool

Returns true if the dataframe contains no rows.

Source

pub fn add_single_column<K, V>( &mut self, key: K, values: V, ) -> Result<(), Error>
where K: Into<Key>, V: Into<TypedDataArray>,

Adds a new column to the dataframe.

The column accepts anything that converts into a crate::TypedData — e.g. Vec<DataValue>, Vec<T> for any supported primitive, Array1<DataValue>, or a raw TypedData.

Returns an error if the column key already exists or if the length of the supplied column does not match the current row count.

Source

pub fn get_column(&self, key: &Key) -> Option<&TypedDataArray>

Returns a reference to the underlying typed column storage, or None if key is absent.

This is the zero-copy counterpart of get_single_column: callers can use TypedData::as_slice_i32 (and its siblings for other primitives) to borrow the native storage without allocating a DataValue per element.

Source

pub fn get_single_column(&self, key: &Key) -> Option<Array1<DataValue>>

👎Deprecated:

allocates O(n); use get_column() for zero-copy typed access

Returns a single column materialized as an owned Array1<DataValue>, or None if the key is absent.

Typed columns allocate a DataValue per element on the fly. For zero-copy typed access, use Self::get_column.

Source

pub fn get_single_column_typed<T: Extract>( &self, key: &Key, ) -> Option<Array1<T>>

Returns a column extracted into a typed Array1<T>, where each DataValue is converted via the Extract trait.

This is a convenience wrapper around get_single_column that maps every element through T::extract, producing an owned array of the target type. Returns None if the key does not exist in the dataframe.

§Type coercion

The Extract trait performs best-effort numeric coercion (e.g. I32 -> f64). Values that cannot be meaningfully converted yield the type’s default (0 for numbers, false for bool, empty string for String).

§Examples
use trs_dataframe::{df, Key};

let df = df! {
    "score" => [1.5f64, 2.5f64, 3.5f64]
};
let key: Key = "score".into();
let col = df.get_single_column_typed::<f64>(&key).unwrap();
assert_eq!(col.len(), 3);
assert_eq!(col[0], 1.5);
Source

pub fn sorted(&self, key: &Key) -> Result<SortedDataFrame<'_>, Error>

Returns a SortedDataFrame view sorted by the given column key.

The sort is ascending with Null values pushed to the end. Use SortedDataFrame::topn to efficiently extract the first/last N rows.

Source

pub fn filter(&self, filter: &FilterRules) -> Result<Self, Error>

Returns a new dataframe containing only rows that satisfy the filter expression.

Filter expressions are parsed from strings — see FilterRules for the supported grammar (comparison, regex, set membership, logical combinators).

Constants and metadata are cloned into the result.

Source

pub fn load_from_messagepack(bytes: &[u8]) -> Result<Self, Error>

Deserializes a dataframe from MessagePack bytes.

This is the inverse of store_into_messagepack and is useful for compact binary serialization in IPC or storage scenarios.

Source

pub fn store_into_messagepack(&self) -> Result<Vec<u8>, Error>

Serializes this dataframe into MessagePack bytes.

The resulting bytes can be deserialized back with load_from_messagepack.

Trait Implementations§

Source§

impl Clone for DataFrame

Source§

fn clone(&self) -> DataFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DataFrame

Source§

fn default() -> DataFrame

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DataFrame

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for DataFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ColumnFrame> for DataFrame

Source§

fn from(dataframe: ColumnFrame) -> Self

Converts to this type from the input type.
Source§

impl From<DataFrameOrDict> for DataFrame

Source§

fn from(value: DataFrameOrDict) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, ArrayBase<OwnedRepr<DataValue>, Dim<[usize; 1]>>>> for DataFrame

Source§

fn from(dataframe: HashMap<String, Array1<DataValue>>) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, Vec<DataValue>>> for DataFrame

Source§

fn from(dataframe: HashMap<String, Vec<DataValue>>) -> Self

Converts to this type from the input type.
Source§

impl From<SizedHashMap<SmartString<LazyCompact>, Vec<DataValue>>> for DataFrame

Source§

fn from(dataframe: MLChefMap) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<(Key, Vec<DataValue>)>> for DataFrame

Source§

fn from(dataframe: Vec<(Key, Vec<DataValue>)>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<HashMap<Key, DataValue>>> for DataFrame

Source§

fn from(dataframe: Vec<HashMap<Key, DataValue>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<SizedHashMap<Key, DataValue>>> for DataFrame

Source§

fn from(dataframe: Vec<HashMap<Key, DataValue>>) -> Self

Converts to this type from the input type.
Source§

impl<'py> IntoPyObject<'py> for DataFrame

Source§

type Target = DataFrame

The Python output type
Source§

type Output = Bound<'py, <DataFrame as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PartialEq for DataFrame

Source§

fn eq(&self, other: &DataFrame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PyClass for DataFrame

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for DataFrame

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

const RAW_DOC: &'static CStr = /// User-facing dataframe: a [`ColumnFrame`] with attached constants and /// metadata. /// /// # Storage /// The underlying [`ColumnFrame`] is column-oriented — each column lives in /// its own [`crate::TypedData`] variant. Materialize a 2-D view /// with [`DataFrame::select`] (row-major) or /// [`DataFrame::select_view`] (zero-copy where possible). /// /// # Example /// ``` /// use trs_dataframe::{DataFrame, column_frame}; /// /// let df = DataFrame::new(column_frame! { /// "a" => [1, 2, 3], /// "b" => [4, 5, 6] /// }); /// /// // Materialize all columns as a row-major 2-D array (rows × columns). /// let all_data = df.select(None); /// /// // Materialize a specific subset of columns. /// let keys = vec!["a".into(), "b".into()]; /// let selected = df.select(Some(&keys)); /// ```

Docstring for the class provided on the struct or enum. Read more
Source§

const DOC: &'static CStr

Fully rendered class doc, including the text_signature if a constructor is defined. Read more
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<DataFrame>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature for DataFrame

Source§

const TEXT_SIGNATURE: &'static str = "()"

Source§

impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder DataFrame

Source§

type Holder = Option<PyClassGuard<'a, DataFrame>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'holder mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder mut DataFrame

Source§

type Holder = Option<PyClassGuardMut<'a, DataFrame>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'holder mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<DataFrame> for PyClassImplCollector<DataFrame>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for DataFrame

Source§

const NAME: &'static str = "DataFrame"

Class name.
Source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
Source§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl Serialize for DataFrame

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl DerefToPyAny for DataFrame

Source§

impl StructuralPartialEq for DataFrame

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

Source§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

Source§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

Source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
Source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Ungil for T
where T: Send,