Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: fix PR07,SA01,ES01 for pandas.Series.sparse.from_coo #59980

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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