| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.SparseCSRMatrix.html | [Back] [Original] |
Section Navigation
Bases: _Weakrefable
A sparse CSR (Compressed Sparse Row) matrix.
CSR format stores a sparse matrix by compressing the row information. It uses three arrays: data (non-zero values), indices (column indices), and indptr (row pointers that indicate where each row starts in the data array).
Examples
>>> import pyarrow as pa
>>> import numpy as np
>>> dense_matrix = np.array([[1, 0, 2], [0, 0, 3]], dtype=np.float64)
>>> sparse_csr = pa.SparseCSRMatrix.from_dense_numpy(dense_matrix)
>>> sparse_csr
<pyarrow.SparseCSRMatrix>
type: double
shape: (2, 3)
Methods
|
|
|
Returns the name of the i-th tensor dimension. |
|
Return true if sparse tensors contains exactly equal data. |
|
Convert numpy.ndarray to arrow::SparseCSRMatrix |
|
Create arrow::SparseCSRMatrix from numpy.ndarrays. |
|
Convert scipy.sparse.csr_array or scipy.sparse.csr_matrix to arrow::SparseCSRMatrix. |
|
Convert arrow::Tensor to arrow::SparseCSRMatrix. |
|
Convert arrow::SparseCSRMatrix to numpy.ndarrays with zero copy. |
|
Convert arrow::SparseCSRMatrix to scipy.sparse.csr_array. |
|
Convert arrow::SparseCSRMatrix to arrow::Tensor. |
Attributes
Returns the name of the i-th tensor dimension.
Return true if sparse tensors contains exactly equal data.
SparseCSRMatrixThe other tensor to compare for equality.
Convert numpy.ndarray to arrow::SparseCSRMatrix
numpy.ndarrayThe dense numpy array that should be converted.
list, optionalThe names of the dimensions.
Create arrow::SparseCSRMatrix from numpy.ndarrays.
numpy.ndarrayData used to populate the sparse matrix.
numpy.ndarrayRange of the rows, The i-th row spans from indptr[i] to indptr[i+1] in the data.
numpy.ndarrayColumn indices of the corresponding non-zero values.
tupleShape of the matrix.
list, optionalNames of the dimensions.
Examples
>>> import pyarrow as pa
>>> import numpy as np
>>> data = np.array([1.0, 2.0, 3.0], dtype=np.float64)
>>> indptr = np.array([0, 2, 3], dtype=np.int64)
>>> indices = np.array([0, 2, 1], dtype=np.int64)
>>> sparse_csr = pa.SparseCSRMatrix.from_numpy(
... data, indptr, indices, shape=(2, 3))
>>> sparse_csr
<pyarrow.SparseCSRMatrix>
type: double
shape: (2, 3)
Convert scipy.sparse.csr_array or scipy.sparse.csr_matrix to arrow::SparseCSRMatrix.
scipy.sparse.csr_array or scipy.sparse.csr_matrixThe scipy matrix that should be converted.
list, optionalNames of the dimensions.
Convert arrow::Tensor to arrow::SparseCSRMatrix.
TensorThe dense tensor that should be converted.
Convert arrow::SparseCSRMatrix to numpy.ndarrays with zero copy.
Convert arrow::SparseCSRMatrix to scipy.sparse.csr_array.
Convert arrow::SparseCSRMatrix to arrow::Tensor.
SparseCSRMatrixSparseCSRMatrix.__init__()SparseCSRMatrix.dim_name()SparseCSRMatrix.dim_namesSparseCSRMatrix.equals()SparseCSRMatrix.from_dense_numpy()SparseCSRMatrix.from_numpy()SparseCSRMatrix.from_scipy()SparseCSRMatrix.from_tensor()SparseCSRMatrix.is_mutableSparseCSRMatrix.ndimSparseCSRMatrix.non_zero_lengthSparseCSRMatrix.shapeSparseCSRMatrix.sizeSparseCSRMatrix.to_numpy()SparseCSRMatrix.to_scipy()SparseCSRMatrix.to_tensor()SparseCSRMatrix.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 |