API: Add sparse Acessor
State: closed

* Adds a Series.sparse accessor
* Adds several methods to SparseArray to for use via the accessor

Closes #23148.

This should provide all the methods / attributes that were available on SparseSeries, but not Series.

Right now the docs for `.sparse.from_coo` and `to_coo` seem to be broken. It's a bit strange since they're implemented on the accessor (they don't make sense on the Array)

Labels:
name: API Design
name: Sparse
description: Sparse Data Type

Comments:
Hello @TomAugspurger! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/arrays/sparse.py`](https://github.com/TomAugspurger/pandas/blob/90100451d4e00650bfdbf09c832c7f3f66d2626f/pandas/core/arrays/sparse.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/accessors.py`](https://github.com/TomAugspurger/pandas/blob/90100451d4e00650bfdbf09c832c7f3f66d2626f/pandas/core/indexes/accessors.py) !

 - There are no PEP8 issues in the file [`pandas/core/series.py`](https://github.com/TomAugspurger/pandas/blob/90100451d4e00650bfdbf09c832c7f3f66d2626f/pandas/core/series.py) !

 - There are no PEP8 issues in the file [`pandas/core/sparse/series.py`](https://github.com/TomAugspurger/pandas/blob/90100451d4e00650bfdbf09c832c7f3f66d2626f/pandas/core/sparse/series.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arrays/sparse/test_array.py`](https://github.com/TomAugspurger/pandas/blob/90100451d4e00650bfdbf09c832c7f3f66d2626f/pandas/tests/arrays/sparse/test_array.py) !


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=h1) Report
> Merging [#23183](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0a2d5019dc2b8f9521879f47a197076d9cef38ce?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `88.09%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23183/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23183      +/-   ##
==========================================
- Coverage   92.23%   92.22%   -0.01%     
==========================================
  Files         169      169              
  Lines       50924    50962      +38     
==========================================
+ Hits        46968    47001      +33     
- Misses       3956     3961       +5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.65% <88.09%> (-0.01%)` | :arrow_down: |
| #single | `42.28% <42.85%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/accessors.py](https://codecov.io/gh/pandas-dev/pandas/pull/23183/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9hY2Nlc3NvcnMucHk=) | `90.09% <ø> (ø)` | :arrow_up: |
| [pandas/core/accessor.py](https://codecov.io/gh/pandas-dev/pandas/pull/23183/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWNjZXNzb3IucHk=) | `98.79% <ø> (ø)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/23183/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `93.87% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/sparse/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/23183/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL3Nlcmllcy5weQ==) | `95.53% <100%> (+0.04%)` | :arrow_up: |
| [pandas/core/arrays/sparse.py](https://codecov.io/gh/pandas-dev/pandas/pull/23183/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3NwYXJzZS5weQ==) | `91.84% <85.29%> (-0.3%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=footer). Last update [0a2d501...e26d48e](https://codecov.io/gh/pandas-dev/pandas/pull/23183?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Latest commit should fix the doc rendering for Series.sparse.to_coo and Series.sparse.from_coo (we just need to use the regular `autosummary` directive, instead of the `autoaccessor`, since the docstring is on the accessor, not the object delegated to).
> For example, do we want to expose the IntIndex and BlockIndex officially as API?

I'm happy to remove those.
Forgot to remove sp_index and kind from the api.rst

This should be ready once it passes.
thanks @TomAugspurger