BUG: Fix (22477) dtype=str converts NaN to 'n'
State: closed

- [x] closes #22477
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Now:
```
>>> import pandas as pd
>>> result = pd.Series(index=range(5), dtype=str)
>>> result
0    NaN
1    NaN
2    NaN
3    NaN
4    NaN
dtype: object
```

This is implemented by adding a check so if the `dtype` is `str` is will create an empty array type object and then pass the values. Two tests have been implemented:

- test for an empty series. To check that it fills the series with NaN and not with 'n'. For example now:
- test for cases that no string values are given.

Labels:
name: Regression
description: Functionality that used to work in a prior pandas version

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

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

```diff
@@            Coverage Diff             @@
##           master   #22564      +/-   ##
==========================================
+ Coverage   92.28%   92.28%   +<.01%     
==========================================
  Files         161      161              
  Lines       51457    51461       +4     
==========================================
+ Hits        47489    47493       +4     
  Misses       3968     3968
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.68% <100%> (ø)` | :arrow_up: |
| #single | `42.31% <28.57%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22564?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/22564/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.99% <100%> (+0.07%)` | :arrow_up: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/22564/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.37% <100%> (ø)` | :arrow_up: |

------

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

Just saw that this failed. I am travelling tomorrow but will pick it up asap :+1: 
@Nikoleta-v3 : Awesome!  Also, don't forget the `whatsnew` entry!
Hey everyone! Thank you very much for your comments. I haven't forgotten about this, I am currently very busy preparing for PyCon UK.

I will make sure to fix the failures and address your comments as soon as possible. 
can you rebase and fixup
Hello @Nikoleta-v3! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/dtypes/cast.py`](https://github.com/Nikoleta-v3/pandas/blob/ee854d7859b5b40f45592148e20408d9d51f24ac/pandas/core/dtypes/cast.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/common.py`](https://github.com/Nikoleta-v3/pandas/blob/ee854d7859b5b40f45592148e20408d9d51f24ac/pandas/core/dtypes/common.py) !

 - There are no PEP8 issues in the file [`pandas/tests/series/test_constructors.py`](https://github.com/Nikoleta-v3/pandas/blob/ee854d7859b5b40f45592148e20408d9d51f24ac/pandas/tests/series/test_constructors.py) !


i think this is fixed now.
Thank you for the commits @jreback :+1: 
ok should be fixed up.
@jorisvandenbossche if you have any other issues.
Thanks @Nikoleta-v3  and @jreback !

> if you have any other issues.

I suppose that integer line is still not covered in the tests, but yeah, that's not related to what this PR was trying to fix.