Skip to content

Commit d697a5f

Browse files
authored
DOC: Update DataFrame.sparse methods' docstring to pass docstring validation (#58323)
* fix docstring error for sparse method * fix line too long * fix see also docstring error * fix line too long * fix sparse.to_dense docstring errors * delete empty line * add see also for sparse.to_coo * correct order
1 parent de1131f commit d697a5f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

ci/code_checks.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9999
-i "pandas.DataFrame.reorder_levels SA01" \
100100
-i "pandas.DataFrame.sem PR01,RT03,SA01" \
101101
-i "pandas.DataFrame.skew RT03,SA01" \
102-
-i "pandas.DataFrame.sparse PR01,SA01" \
103-
-i "pandas.DataFrame.sparse.density SA01" \
104-
-i "pandas.DataFrame.sparse.from_spmatrix SA01" \
105-
-i "pandas.DataFrame.sparse.to_coo SA01" \
106-
-i "pandas.DataFrame.sparse.to_dense SA01" \
102+
-i "pandas.DataFrame.sparse PR01" \
107103
-i "pandas.DataFrame.std PR01,RT03,SA01" \
108104
-i "pandas.DataFrame.sum RT03" \
109105
-i "pandas.DataFrame.swaplevel SA01" \

pandas/core/arrays/sparse/accessor.py

+23
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ class SparseFrameAccessor(BaseAccessor, PandasDelegate):
243243
"""
244244
DataFrame accessor for sparse data.
245245
246+
See Also
247+
--------
248+
DataFrame.sparse.density : Ratio of non-sparse points to total (dense) data points.
249+
246250
Examples
247251
--------
248252
>>> df = pd.DataFrame({"a": [1, 2, 0, 0], "b": [3, 0, 0, 4]}, dtype="Sparse[int]")
@@ -274,6 +278,11 @@ def from_spmatrix(cls, data, index=None, columns=None) -> DataFrame:
274278
Each column of the DataFrame is stored as a
275279
:class:`arrays.SparseArray`.
276280
281+
See Also
282+
--------
283+
DataFrame.sparse.to_coo : Return the contents of the frame as a
284+
sparse SciPy COO matrix.
285+
277286
Examples
278287
--------
279288
>>> import scipy.sparse
@@ -319,6 +328,11 @@ def to_dense(self) -> DataFrame:
319328
DataFrame
320329
A DataFrame with the same values stored as dense arrays.
321330
331+
See Also
332+
--------
333+
DataFrame.sparse.density : Ratio of non-sparse points to total
334+
(dense) data points.
335+
322336
Examples
323337
--------
324338
>>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0])})
@@ -343,6 +357,10 @@ def to_coo(self) -> spmatrix:
343357
If the caller is heterogeneous and contains booleans or objects,
344358
the result will be of dtype=object. See Notes.
345359
360+
See Also
361+
--------
362+
DataFrame.sparse.to_dense : Convert a DataFrame with sparse values to dense.
363+
346364
Notes
347365
-----
348366
The dtype will be the lowest-common-denominator type (implicit
@@ -388,6 +406,11 @@ def density(self) -> float:
388406
"""
389407
Ratio of non-sparse points to total (dense) data points.
390408
409+
See Also
410+
--------
411+
DataFrame.sparse.from_spmatrix : Create a new DataFrame from a
412+
scipy sparse matrix.
413+
391414
Examples
392415
--------
393416
>>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0, 1])})

0 commit comments

Comments
 (0)