pandas.SparseSeries.from_coo
-
classmethod SparseSeries.from_coo(A, dense_index=False)[source] -
Создайте SparseSeries из scipy.sparse.coo_matrix.
Параметры: A : scipy.sparse.coo_matrix
dense_index : bool, по умолчанию False
Если False (по умолчанию), индекс SparseSeries состоит только из координат ненулевых элементов исходной coo_matrix. Если True, индекс SparseSeries состоит из полных отсортированных (строка, столбец) координат coo_matrix.
Возвращает: s : SparseSeries
Примеры
>>> from scipy import sparse >>> A = sparse.coo_matrix(([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])), shape=(3, 4)) >>> A <3x4 sparse matrix of type '<class 'numpy.float64'>' with 3 stored elements in COOrdinate format> >>> A.todense() matrix([[ 0., 0., 1., 2.], [ 3., 0., 0., 0.], [ 0., 0., 0., 0.]]) >>> ss = SparseSeries.from_coo(A) >>> ss 0 2 1 3 2 1 0 3 dtype: float64 BlockIndex Block locations: array([0], dtype=int32) Block lengths: array([3], dtype=int32)
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.21.1/generated/pandas.SparseSeries.from_coo.html