Skip to content

Commit 254720a

Browse files
authored
TST: move Series.map tests to tests/series/methods/test_map.py (#52384)
* TST: move Series.map tests to tests/series/methods/test_map.py * add gh number * fix pre-commit
1 parent 6d36c45 commit 254720a

File tree

4 files changed

+589
-434
lines changed

4 files changed

+589
-434
lines changed

doc/source/whatsnew/v2.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ Other
323323
- Bug in :func:`assert_almost_equal` now throwing assertion error for two unequal sets (:issue:`51727`)
324324
- Bug in :meth:`Series.memory_usage` when ``deep=True`` throw an error with Series of objects and the returned value is incorrect, as it does not take into account GC corrections (:issue:`51858`)
325325
- Bug in :func:`assert_frame_equal` checks category dtypes even when asked not to check index type (:issue:`52126`)
326+
- Bug in :meth:`Series.map` when giving a callable to an empty series, the returned series had ``object`` dtype. It now keeps the original dtype (:issue:`52384`)
326327

327328
.. ***DO NOT USE THIS SECTION***
328329

pandas/core/algorithms.py

+3
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,9 @@ def map_array(
17461746

17471747
return new_values
17481748

1749+
if not len(arr):
1750+
return arr.copy()
1751+
17491752
# we must convert to python types
17501753
values = arr.astype(object, copy=False)
17511754
if na_action is None:

0 commit comments

Comments
 (0)