pub struct SparseAccessor<'a> { /* private fields */ }Expand description
Accessor for sparse operations on a Series.
Created by Series::sparse(). Provides the pandas Series.sparse
namespace over the column’s compressed sparse storage.
Implementations§
Source§impl SparseAccessor<'_>
impl SparseAccessor<'_>
Sourcepub fn value_dtype(&self) -> DType
pub fn value_dtype(&self) -> DType
Return the logical sparse value dtype.
Matches pd.Series.dtype.subtype (measured 2.2.3: float64 for a
Sparse[float64] Series).
⚠️ The path cited before, pd.Series.sparse.dtype, does not exist. The
.sparse accessor carries density/fill_value/sp_values/to_dense;
the dtype, and its subtype, hangs off the Series itself.
Sourcepub fn fill_value(&self) -> &Scalar
pub fn fill_value(&self) -> &Scalar
Return the sparse fill value.
Matches pd.Series.sparse.fill_value.
Sourcepub fn npoints(&self) -> usize
pub fn npoints(&self) -> usize
Count stored values, including explicit entries equal to the fill.
Matches the SparseArray.sp_values cardinality used by pandas density.
Sourcepub fn sp_values(&self) -> Vec<Scalar>
pub fn sp_values(&self) -> Vec<Scalar>
Return the explicitly stored values as a Vec.
Matches pd.Series.sparse.sp_values (returns underlying non-fill data).
Sourcepub fn sp_index(&self) -> Vec<usize>
pub fn sp_index(&self) -> Vec<usize>
Return the indices of explicitly stored values.
Arithmetic can leave a stored entry equal to the fill value; its position still belongs to the sparse index.
Sourcepub fn density(&self) -> f64
pub fn density(&self) -> f64
Return non-fill density as npoints / len.
Matches pd.Series.sparse.density (NaN when the Series is empty: 0 / 0).
Sourcepub fn from_coo(
name: impl Into<LabelName>,
data: Vec<Scalar>,
row_indices: &[usize],
col_indices: &[usize],
shape: (usize, usize),
value_dtype: DType,
dense_index: bool,
) -> Result<Series, FrameError>
pub fn from_coo( name: impl Into<LabelName>, data: Vec<Scalar>, row_indices: &[usize], col_indices: &[usize], shape: (usize, usize), value_dtype: DType, dense_index: bool, ) -> Result<Series, FrameError>
Construct a sparse Series from COO (data, row_indices, col_indices) triplets.
Matches pd.Series.sparse.from_coo(A, dense_index=...).
Sourcepub fn to_coo(
&self,
sort_labels: bool,
) -> Result<(Vec<Scalar>, Vec<usize>, Vec<usize>, Vec<IndexLabel>, Vec<IndexLabel>), FrameError>
pub fn to_coo( &self, sort_labels: bool, ) -> Result<(Vec<Scalar>, Vec<usize>, Vec<usize>, Vec<IndexLabel>, Vec<IndexLabel>), FrameError>
Export non-fill entries as COO (values, row_coords, col_coords, row_labels, col_labels).
Matches pd.Series.sparse.to_coo(sort_labels=...).
Sourcepub fn to_dense(&self) -> Result<Series, FrameError>
pub fn to_dense(&self) -> Result<Series, FrameError>
Materialize this sparse Series as a dense Series.
Matches pd.Series.sparse.to_dense().
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SparseAccessor<'a>
impl<'a> !UnwindSafe for SparseAccessor<'a>
impl<'a> Forget for SparseAccessor<'a>
impl<'a> Freeze for SparseAccessor<'a>
impl<'a> Move for SparseAccessor<'a>
impl<'a> Send for SparseAccessor<'a>
impl<'a> Sync for SparseAccessor<'a>
impl<'a> Unpin for SparseAccessor<'a>
impl<'a> UnsafeUnpin for SparseAccessor<'a>
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
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> ⓘ
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> ⓘ
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