Description
Code Sample, a copy-pastable example if possible
pd.Series(list('abc') + [np.nan]).map({np.nan: 'bar'})
Result:
0 NaN
1 NaN
2 NaN
3 NaN
dtype: float64
Compare:
pd.Series(list('abc') + [np.nan]).map({'a': 'foo', np.nan: 'bar'})
Result:
0 foo
1 NaN
2 NaN
3 bar
dtype: object
Problem description
If only np.nan
is present in the mapping, then the associated mapping is not carried out. If another value is present, then it is carried out. Forgive me if this is intended behavior for some reason.
Expected Output
I'm not sure what is appropriate here.
Output of pd.show_versions()
pandas: 0.22.0
pytest: None
pip: 8.1.1
setuptools: 20.7.0
Cython: None
numpy: 1.11.0
scipy: 0.17.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: 0.5.0
dateutil: 2.4.2
pytz: 2014.10
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.4.3
feather: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.6.0