Skip to content

DOC: Update DataFrame.sparse methods' docstring to pass docstring validation #58323

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

Merged
merged 8 commits into from
Apr 20, 2024
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
6 changes: 1 addition & 5 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.reorder_levels SA01" \
-i "pandas.DataFrame.sem PR01,RT03,SA01" \
-i "pandas.DataFrame.skew RT03,SA01" \
-i "pandas.DataFrame.sparse PR01,SA01" \
-i "pandas.DataFrame.sparse.density SA01" \
-i "pandas.DataFrame.sparse.from_spmatrix SA01" \
-i "pandas.DataFrame.sparse.to_coo SA01" \
-i "pandas.DataFrame.sparse.to_dense SA01" \
-i "pandas.DataFrame.sparse PR01" \
-i "pandas.DataFrame.std PR01,RT03,SA01" \
-i "pandas.DataFrame.sum RT03" \
-i "pandas.DataFrame.swaplevel SA01" \
Expand Down
23 changes: 23 additions & 0 deletions pandas/core/arrays/sparse/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ class SparseFrameAccessor(BaseAccessor, PandasDelegate):
"""
DataFrame accessor for sparse data.

See Also
--------
DataFrame.sparse.density : Ratio of non-sparse points to total (dense) data points.

Examples
--------
>>> df = pd.DataFrame({"a": [1, 2, 0, 0], "b": [3, 0, 0, 4]}, dtype="Sparse[int]")
Expand Down Expand Up @@ -274,6 +278,11 @@ def from_spmatrix(cls, data, index=None, columns=None) -> DataFrame:
Each column of the DataFrame is stored as a
:class:`arrays.SparseArray`.

See Also
--------
DataFrame.sparse.to_coo : Return the contents of the frame as a
sparse SciPy COO matrix.

Examples
--------
>>> import scipy.sparse
Expand Down Expand Up @@ -319,6 +328,11 @@ def to_dense(self) -> DataFrame:
DataFrame
A DataFrame with the same values stored as dense arrays.

See Also
--------
DataFrame.sparse.density : Ratio of non-sparse points to total
(dense) data points.

Examples
--------
>>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0])})
Expand All @@ -343,6 +357,10 @@ def to_coo(self) -> spmatrix:
If the caller is heterogeneous and contains booleans or objects,
the result will be of dtype=object. See Notes.

See Also
--------
DataFrame.sparse.to_dense : Convert a DataFrame with sparse values to dense.

Notes
-----
The dtype will be the lowest-common-denominator type (implicit
Expand Down Expand Up @@ -388,6 +406,11 @@ def density(self) -> float:
"""
Ratio of non-sparse points to total (dense) data points.

See Also
--------
DataFrame.sparse.from_spmatrix : Create a new DataFrame from a
scipy sparse matrix.

Examples
--------
>>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0, 1])})
Expand Down