| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.SparseCOOTensor.html | [Back] [Original] |
Section Navigation
Bases: _Weakrefable
A sparse COO (COOrdinate) tensor.
COO format stores a sparse tensor as a collection of (indices, values) pairs. The indices specify the coordinates of non-zero elements, and the values contain the actual data at those coordinates.
Examples
>>> import pyarrow as pa
>>> import numpy as np
>>> dense_tensor = np.array([[0, 1, 0], [2, 0, 3]], dtype=np.float32)
>>> sparse_coo = pa.SparseCOOTensor.from_dense_numpy(dense_tensor)
>>> sparse_coo
<pyarrow.SparseCOOTensor>
type: float
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::SparseCOOTensor |
|
Create arrow::SparseCOOTensor from numpy.ndarrays |
|
Convert pydata/sparse.COO to arrow::SparseCOOTensor. |
|
Convert scipy.sparse.coo_array or scipy.sparse.coo_matrix to arrow::SparseCOOTensor |
|
Convert arrow::Tensor to arrow::SparseCOOTensor. |
|
Convert arrow::SparseCOOTensor to numpy.ndarrays with zero copy. |
|
Convert arrow::SparseCOOTensor to pydata/sparse.COO. |
|
Convert arrow::SparseCOOTensor to scipy.sparse.coo_array. |
|
Convert arrow::SparseCOOTensor to arrow::Tensor. |
Attributes
Returns the name of the i-th tensor dimension.
Return true if sparse tensors contains exactly equal data.
SparseCOOTensorThe other tensor to compare for equality.
Convert numpy.ndarray to arrow::SparseCOOTensor
numpy.ndarrayData used to populate the rows.
list[str], optionalNames of the dimensions.
Create arrow::SparseCOOTensor from numpy.ndarrays
numpy.ndarrayData used to populate the rows.
numpy.ndarrayCoordinates of the data.
tupleShape of the tensor.
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.float32)
>>> coords = np.array([[0, 1], [1, 0], [1, 2]], dtype=np.int64)
>>> sparse_coo = pa.SparseCOOTensor.from_numpy(data, coords, shape=(2, 3))
>>> sparse_coo
<pyarrow.SparseCOOTensor>
type: float
shape: (2, 3)
Convert pydata/sparse.COO to arrow::SparseCOOTensor.
pydata.sparse.COOThe sparse multidimensional array that should be converted.
list, optionalNames of the dimensions.
Convert scipy.sparse.coo_array or scipy.sparse.coo_matrix to arrow::SparseCOOTensor
scipy.sparse.coo_array or scipy.sparse.coo_matrixThe scipy array or matrix that should be converted.
list, optionalNames of the dimensions.
Convert arrow::Tensor to arrow::SparseCOOTensor.
TensorThe tensor that should be converted.
Convert arrow::SparseCOOTensor to numpy.ndarrays with zero copy.
Convert arrow::SparseCOOTensor to pydata/sparse.COO.
Convert arrow::SparseCOOTensor to scipy.sparse.coo_array.
Convert arrow::SparseCOOTensor to arrow::Tensor.
SparseCOOTensorSparseCOOTensor.__init__()SparseCOOTensor.dim_name()SparseCOOTensor.dim_namesSparseCOOTensor.equals()SparseCOOTensor.from_dense_numpy()SparseCOOTensor.from_numpy()SparseCOOTensor.from_pydata_sparse()SparseCOOTensor.from_scipy()SparseCOOTensor.from_tensor()SparseCOOTensor.has_canonical_formatSparseCOOTensor.is_mutableSparseCOOTensor.ndimSparseCOOTensor.non_zero_lengthSparseCOOTensor.shapeSparseCOOTensor.sizeSparseCOOTensor.to_numpy()SparseCOOTensor.to_pydata_sparse()SparseCOOTensor.to_scipy()SparseCOOTensor.to_tensor()SparseCOOTensor.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 |