BUG: SparseSeries init from dict fixes
State: closed

 - [X] closes #16905
 - [X] tests added / passed
 - [X] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff`` (On Windows, ``git diff upstream/master -u -- "*.py" | flake8 --diff`` might work as an alternative.)
 - [X] whatsnew entry

Labels:
name: Bug
name: Duplicate Report
description: Duplicate issue or pull request
name: Sparse
description: Sparse Data Type

Comments:
Tests copied/adapted from `tests.series.test_constructors`.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=h1) Report
> Merging [#16906](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/692b5eeeff9b8e8c750f3e64db0c39dc149a73e8?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16906      +/-   ##
==========================================
- Coverage   90.99%   90.97%   -0.02%     
==========================================
  Files         161      161              
  Lines       49293    49292       -1     
==========================================
- Hits        44854    44844      -10     
- Misses       4439     4448       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.74% <100%> (-0.01%)` | :arrow_down: |
| #single | `40.19% <100%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/sparse/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL3Nlcmllcy5weQ==) | `95.06% <100%> (-0.02%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.76% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16906?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/16906?src=pr&el=footer). Last update [692b5ee...659559c](https://codecov.io/gh/pandas-dev/pandas/pull/16906?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@kernc lmk if you are able to share some test code with Series, can always do a followup.
Hello @kernc! Thanks for updating the PR.



 - In the file [`pandas/tests/series/test_api.py`](https://github.com/pandas-dev/pandas/blob/659559c8f11bb71ea1b74c678b9ed319df86165e/pandas/tests/series/test_api.py), following are the PEP8 issues :

> [Line 128:80](https://github.com/pandas-dev/pandas/blob/659559c8f11bb71ea1b74c678b9ed319df86165e/pandas/tests/series/test_api.py#L128): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (83 > 79 characters)
> [Line 166:32](https://github.com/pandas-dev/pandas/blob/659559c8f11bb71ea1b74c678b9ed319df86165e/pandas/tests/series/test_api.py#L166): [E128](https://duckduckgo.com/?q=pep8%20E128) continuation line under-indented for visual indent











##### Comment last updated on July 17, 2017 at 21:25 Hours UTC
Was able to share some test code with Series with as little as possible effort. Not sure if OK, though.
> Was able to share some test code with Series with as little as possible effort. Not sure if OK, though.

I'm a little hesitant about this code-sharing because the readability decreased IMO.  `self.Series` for me a just a little harder to understand.
How else would you share code without `self.Series`? And if you'd rather not share code, how else would you ensure the two _is-a-Series_ types get roughly the same amount of use case and API coverage?
@kernc this looks fine. ping on green.
> How else would you share code without self.Series?

I personally find the name a little confusing because I only think the `Series` class and not `SparseSeries`, even though the latter is a subclass of the former. 😄 

A name like `self.series_klass` might have been easier because it doesn't have that confusion of naming.
@kernc would you be ok with merging #16960, close this, then you can refactor tests in a new PR?
Of course.
Continued in https://github.com/pandas-dev/pandas/pull/17050.