diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index 38792c46e5f54..5d40541f1d37b 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -464,7 +464,7 @@ be stored efficiently as a :class:`arrays.SparseArray`. The ``Series.sparse`` accessor may be used to access sparse-specific attributes and methods if the :class:`Series` contains sparse values. See -:ref:`api.series.sparse` for more. +:ref:`api.series.sparse` and :ref:`the user guide ` for more. .. _api.arrays.string: diff --git a/doc/source/user_guide/sparse.rst b/doc/source/user_guide/sparse.rst index b2b3678e48534..ef2cb8909b59d 100644 --- a/doc/source/user_guide/sparse.rst +++ b/doc/source/user_guide/sparse.rst @@ -23,7 +23,7 @@ array that are ``nan`` aren't actually stored, only the non-``nan`` elements are Those non-``nan`` elements have a ``float64`` dtype. The sparse objects exist for memory efficiency reasons. Suppose you had a -large, mostly NA ``DataFrame``: +large, mostly NA :class:`DataFrame`: .. ipython:: python @@ -139,7 +139,7 @@ Sparse calculation ------------------ You can apply NumPy `ufuncs `_ -to ``SparseArray`` and get a ``SparseArray`` as a result. +to :class:`arrays.SparseArray` and get a :class:`arrays.SparseArray` as a result. .. ipython:: python @@ -183,7 +183,7 @@ your code, rather than ignoring the warning. **Construction** From an array-like, use the regular :class:`Series` or -:class:`DataFrame` constructors with :class:`SparseArray` values. +:class:`DataFrame` constructors with :class:`arrays.SparseArray` values. .. code-block:: python @@ -240,7 +240,7 @@ Sparse-specific properties, like ``density``, are available on the ``.sparse`` a **General differences** In a ``SparseDataFrame``, *all* columns were sparse. A :class:`DataFrame` can have a mixture of -sparse and dense columns. As a consequence, assigning new columns to a ``DataFrame`` with sparse +sparse and dense columns. As a consequence, assigning new columns to a :class:`DataFrame` with sparse values will not automatically convert the input to be sparse. .. code-block:: python @@ -269,7 +269,7 @@ have no replacement. Interaction with scipy.sparse ----------------------------- -Use :meth:`DataFrame.sparse.from_spmatrix` to create a ``DataFrame`` with sparse values from a sparse matrix. +Use :meth:`DataFrame.sparse.from_spmatrix` to create a :class:`DataFrame` with sparse values from a sparse matrix. .. versionadded:: 0.25.0 @@ -294,9 +294,9 @@ To convert back to sparse SciPy matrix in COO format, you can use the :meth:`Dat sdf.sparse.to_coo() -:meth:`Series.sparse.to_coo` is implemented for transforming a ``Series`` with sparse values indexed by a :class:`MultiIndex` to a :class:`scipy.sparse.coo_matrix`. +:meth:`Series.sparse.to_coo` is implemented for transforming a :class:`Series` with sparse values indexed by a :class:`MultiIndex` to a :class:`scipy.sparse.coo_matrix`. -The method requires a ``MultiIndex`` with two or more levels. +The method requires a :class:`MultiIndex` with two or more levels. .. ipython:: python @@ -315,7 +315,7 @@ The method requires a ``MultiIndex`` with two or more levels. ss = s.astype('Sparse') ss -In the example below, we transform the ``Series`` to a sparse representation of a 2-d array by specifying that the first and second ``MultiIndex`` levels define labels for the rows and the third and fourth levels define labels for the columns. We also specify that the column and row labels should be sorted in the final sparse representation. +In the example below, we transform the :class:`Series` to a sparse representation of a 2-d array by specifying that the first and second ``MultiIndex`` levels define labels for the rows and the third and fourth levels define labels for the columns. We also specify that the column and row labels should be sorted in the final sparse representation. .. ipython:: python @@ -341,7 +341,7 @@ Specifying different row and column labels (and not sorting them) yields a diffe rows columns -A convenience method :meth:`Series.sparse.from_coo` is implemented for creating a ``Series`` with sparse values from a ``scipy.sparse.coo_matrix``. +A convenience method :meth:`Series.sparse.from_coo` is implemented for creating a :class:`Series` with sparse values from a ``scipy.sparse.coo_matrix``. .. ipython:: python @@ -350,7 +350,7 @@ A convenience method :meth:`Series.sparse.from_coo` is implemented for creating A A.todense() -The default behaviour (with ``dense_index=False``) simply returns a ``Series`` containing +The default behaviour (with ``dense_index=False``) simply returns a :class:`Series` containing only the non-null entries. .. ipython:: python