Skip to content

Commit

Permalink
DOC: fix PR07,SA01,ES01 for pandas.Series.sparse.from_coo
Browse files Browse the repository at this point in the history
  • Loading branch information
tuhinsharma121 committed Oct 6, 2024
1 parent 05fa958 commit 2acaea4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Series.dt.tz_localize PR01,PR02" \
-i "pandas.Series.dt.unit GL08" \
-i "pandas.Series.pad PR01,SA01" \
-i "pandas.Series.sparse.from_coo PR07,SA01" \
-i "pandas.Timedelta.max PR02" \
-i "pandas.Timedelta.min PR02" \
-i "pandas.Timedelta.resolution PR02" \
Expand Down
14 changes: 14 additions & 0 deletions pandas/core/arrays/sparse/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
"""
Create a Series with sparse values from a scipy.sparse.coo_matrix.
This method takes a ``scipy.sparse.coo_matrix`` (coordinate format) as input and
returns a pandas ``Series`` where the non-zero elements are represented as
sparse values. The index of the Series can either include only the coordinates
of non-zero elements (default behavior) or the full sorted set of coordinates
from the matrix if ``dense_index`` is set to `True`.
Parameters
----------
A : scipy.sparse.coo_matrix
The sparse matrix in coordinate format from which the sparse Series
will be created.
dense_index : bool, default False
If False (default), the index consists of only the
coords of the non-null entries of the original coo_matrix.
Expand All @@ -102,6 +110,12 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
s : Series
A Series with sparse values.
See Also
--------
DataFrame.sparse.from_spmatrix : Create a new DataFrame from a scipy sparse
matrix.
scipy.sparse.coo_matrix : A sparse matrix in COOrdinate format.
Examples
--------
>>> from scipy import sparse
Expand Down

0 comments on commit 2acaea4

Please sign in to comment.