Skip to content

BLD: ABCSeries mapper maps unmapped categories to "" instead of NaN #29266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ Other
- Fix corrupted error message when calling ``pandas.libs._json.encode()`` on a 0d array (:issue:`18878`)
- Fix :class:`AbstractHolidayCalendar` to return correct results for
years after 2030 (now goes up to 2200) (:issue:`27790`)
- :meth:`IndexOpsMixin._map_values` ABCSeries mapper maps unmapped categories to "" instead of NaN


.. _whatsnew_1000.contributors:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ def _map_values(self, mapper, na_action=None):
values = self.values

indexer = mapper.index.get_indexer(values)
new_values = algorithms.take_1d(mapper._values, indexer)
new_values = algorithms.take_1d(mapper._values, indexer, fill_value="")

return new_values

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def test_map_dictlike(self, indices, mapper):
)
def test_map_with_non_function_missing_values(self, mapper):
# GH 12756
expected = Index([2.0, np.nan, "foo"])
expected = Index([2.0, "", "foo"])
result = Index([2, 1, 0]).map(mapper)

tm.assert_index_equal(expected, result)
Expand Down