| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.SparseCSFTensor.html | [Back] [Original] |
Section Navigation
Bases: _Weakrefable
A sparse CSF tensor.
CSF is a generalization of compressed sparse row (CSR) index.
CSF index recursively compresses each dimension of a tensor into a set of prefix trees. Each path from a root to leaf forms one tensor non-zero index. CSF is implemented with two arrays of buffers and one arrays of integers.
Examples
>>> import pyarrow as pa
>>> import numpy as np
>>> # Create a 3D sparse tensor
>>> dense_tensor = np.zeros((2, 3, 2), dtype=np.float32)
>>> dense_tensor[0, 1, 0] = 1.0
>>> dense_tensor[1, 2, 1] = 2.0
>>> sparse_csf = pa.SparseCSFTensor.from_dense_numpy(dense_tensor)
>>> sparse_csf
<pyarrow.SparseCSFTensor>
type: float
shape: (2, 3, 2)
Methods
|
|
|
Returns the name of the i-th tensor dimension. |
|
Return true if sparse tensors contains exactly equal data |
|
Convert numpy.ndarray to arrow::SparseCSFTensor |
|
Create arrow::SparseCSFTensor from numpy.ndarrays |
|
Convert arrow::Tensor to arrow::SparseCSFTensor |
|
Convert arrow::SparseCSFTensor to numpy.ndarrays with zero copy |
|
Convert arrow::SparseCSFTensor to arrow::Tensor |
Attributes
Returns the name of the i-th tensor dimension.
Return true if sparse tensors contains exactly equal data
SparseCSFTensorThe other tensor to compare for equality.
Convert numpy.ndarray to arrow::SparseCSFTensor
numpy.ndarrayData used to populate the rows.
list[str], optionalNames of the dimensions.
Create arrow::SparseCSFTensor from numpy.ndarrays
numpy.ndarrayData used to populate the sparse tensor.
numpy.ndarrayThe sparsity structure. Each two consecutive dimensions in a tensor correspond to a buffer in indices. A pair of consecutive values at indptr[dim][i] indptr[dim][i + 1] signify a range of nodes in indices[dim + 1] who are children of indices[dim][i] node.
numpy.ndarrayStores values of nodes. Each tensor dimension corresponds to a buffer in indptr.
tupleShape of the matrix.
list, optionalthe sequence in which dimensions were traversed to produce the prefix tree.
list, optionalNames of the dimensions.
Examples
>>> import pyarrow as pa
>>> import numpy as np
>>> data = np.array([1.0, 2.0], dtype=np.float32)
>>> indptr = [
... np.array([0, 1, 2], dtype=np.int64),
... np.array([0, 1, 2], dtype=np.int64),
... ]
>>> indices = [
... np.array([0, 1], dtype=np.int64),
... np.array([1, 2], dtype=np.int64),
... np.array([0, 1], dtype=np.int64),
... ]
>>> sparse_csf = pa.SparseCSFTensor.from_numpy(
... data, indptr, indices, shape=(2, 3, 2))
>>> sparse_csf
<pyarrow.SparseCSFTensor>
type: float
shape: (2, 3, 2)
Convert arrow::Tensor to arrow::SparseCSFTensor
TensorThe dense tensor that should be converted.
Convert arrow::SparseCSFTensor to numpy.ndarrays with zero copy
Convert arrow::SparseCSFTensor to arrow::Tensor
SparseCSFTensorSparseCSFTensor.__init__()SparseCSFTensor.dim_name()SparseCSFTensor.dim_namesSparseCSFTensor.equals()SparseCSFTensor.from_dense_numpy()SparseCSFTensor.from_numpy()SparseCSFTensor.from_tensor()SparseCSFTensor.is_mutableSparseCSFTensor.ndimSparseCSFTensor.non_zero_lengthSparseCSFTensor.shapeSparseCSFTensor.sizeSparseCSFTensor.to_numpy()SparseCSFTensor.to_tensor()SparseCSFTensor.type
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |