@@ -79,6 +79,10 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
79
79
Parameters
80
80
----------
81
81
A : scipy.sparse.coo_matrix
82
+ A sparse matrix in COOrdinate format. The matrix should have
83
+ non-zero elements that will be used to create a Series with sparse
84
+ values. The row and column indices of these elements form the index
85
+ of the Series.
82
86
dense_index : bool, default False
83
87
If False (default), the index consists of only the
84
88
coords of the non-null entries of the original coo_matrix.
@@ -90,6 +94,14 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
90
94
s : Series
91
95
A Series with sparse values.
92
96
97
+ See Also
98
+ --------
99
+ scipy.sparse.coo_matrix : Sparse matrix in COOrdinate format.
100
+ pd.Series.sparse : Accessor object for sparse data in a Series.
101
+ pd.DataFrame.sparse.from_spmatrix : Create a DataFrame with sparse
102
+ values from a scipy sparse matrix.
103
+ pd.SparseArray : Array type for storing sparse data.
104
+
93
105
Examples
94
106
--------
95
107
>>> from scipy import sparse
@@ -135,7 +147,13 @@ def to_coo(
135
147
Parameters
136
148
----------
137
149
row_levels : tuple/list
150
+ The levels of the MultiIndex to use for the row coordinates in the
151
+ resulting sparse matrix. These can be specified as the names or
152
+ numerical positions of the levels.
138
153
column_levels : tuple/list
154
+ The levels of the MultiIndex to use for the column coordinates in the
155
+ resulting sparse matrix. These can be specified as the names or
156
+ numerical positions of the levels.
139
157
sort_labels : bool, default False
140
158
Sort the row and column labels before forming the sparse matrix.
141
159
When `row_levels` and/or `column_levels` refer to a single level,
@@ -144,8 +162,22 @@ def to_coo(
144
162
Returns
145
163
-------
146
164
y : scipy.sparse.coo_matrix
165
+ A sparse matrix in COOrdinate format representing the non-NA values
166
+ of the Series.
147
167
rows : list (row labels)
168
+ The row labels corresponding to the row coordinates in the sparse matrix.
148
169
columns : list (column labels)
170
+ The column labels corresponding to the column coordinates in the sparse
171
+ matrix.
172
+
173
+ See Also
174
+ --------
175
+ scipy.sparse.coo_matrix : Sparse matrix in COOrdinate format.
176
+ pd.Series.sparse.from_coo : Create a Series with sparse values from a
177
+ scipy.sparse.coo_matrix.
178
+ pd.DataFrame.sparse.from_spmatrix : Create a DataFrame with sparse values
179
+ from a scipy sparse matrix.
180
+ pd.SparseArray : Array type for storing sparse data.
149
181
150
182
Examples
151
183
--------
0 commit comments