Skip to content

Commit 70be935

Browse files
committed
Merge pull request #8026 from jreback/series_map
BUG: related to GH5080, get_indexer choking on boolean type promotion (GH8024)
2 parents 534784b + 63bbd85 commit 70be935

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

doc/source/v0.15.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Internal Refactoring
217217

218218
In 0.15.0 ``Index`` has internally been refactored to no longer sub-class ``ndarray``
219219
but instead subclass ``PandasObject``, similarly to the rest of the pandas objects. This change allows very easy sub-classing and creation of new index types. This should be
220-
a transparent change with only very limited API implications (:issue:`5080`, :issue:`7439`, :issue:`7796`)
220+
a transparent change with only very limited API implications (:issue:`5080`, :issue:`7439`, :issue:`7796`, :issue:`8024`)
221221

222222
- you may need to unpickle pandas version < 0.15.0 pickles using ``pd.read_pickle`` rather than ``pickle.load``. See :ref:`pickle docs <io.pickle>`
223223
- when plotting with a ``PeriodIndex``. The ``matplotlib`` internal axes will now be arrays of ``Period`` rather than a ``PeriodIndex``. (this is similar to how a ``DatetimeIndex`` passes arrays of ``datetimes`` now)

pandas/core/index.py

+3
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,9 @@ def _possibly_promote(self, other):
15061506
from pandas.tseries.index import DatetimeIndex
15071507
if self.inferred_type == 'date' and isinstance(other, DatetimeIndex):
15081508
return DatetimeIndex(self), other
1509+
elif self.inferred_type == 'boolean':
1510+
if self.dtype != 'object':
1511+
return self.astype('object'), other.astype('object')
15091512
return self, other
15101513

15111514
def groupby(self, to_groupby):

pandas/tests/test_series.py

+7
Original file line numberDiff line numberDiff line change
@@ -4968,6 +4968,13 @@ def test_map(self):
49684968
result = self.ts.map(lambda x: x * 2)
49694969
self.assert_numpy_array_equal(result, self.ts * 2)
49704970

4971+
def test_map_compat(self):
4972+
# related GH 8024
4973+
s = Series([True,True,False],index=[1,2,3])
4974+
result = s.map({ True : 'foo', False : 'bar' })
4975+
expected = Series(['foo','foo','bar'],index=[1,2,3])
4976+
assert_series_equal(result,expected)
4977+
49714978
def test_map_int(self):
49724979
left = Series({'a': 1., 'b': 2., 'c': 3., 'd': 4})
49734980
right = Series({1: 11, 2: 22, 3: 33})

0 commit comments

Comments
 (0)