Skip to content

Commit b8b3edc

Browse files
author
Chang She
committed
BUG: PeriodIndex.map tries to get super(DatetimIndex, self)
1 parent 88d4598 commit b8b3edc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pandas/tseries/period.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def map(self, func_to_map):
753753
try:
754754
return func_to_map(self)
755755
except:
756-
return super(DatetimeIndex, self).map(func_to_map)
756+
return super(PeriodIndex, self).map(func_to_map)
757757

758758
def _mpl_repr(self):
759759
# how to represent ourselves to matplotlib

pandas/tseries/tests/test_period.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import unittest
1212

1313
from numpy.ma.testutils import assert_equal
14+
from numpy.testing import assert_array_equal
1415

1516
from pandas.tseries.frequencies import MONTHS, DAYS
1617
from pandas.tseries.period import Period, PeriodIndex, period_range
@@ -1515,6 +1516,12 @@ def test_is_full(self):
15151516

15161517
self.assert_(index[:0].is_full)
15171518

1519+
def test_map(self):
1520+
index = PeriodIndex([2005, 2007, 2009], freq='A')
1521+
result = index.map(lambda x: x + 1)
1522+
expected = index + 1
1523+
assert_array_equal(result, expected)
1524+
15181525
def _permute(obj):
15191526
return obj.take(np.random.permutation(len(obj)))
15201527

0 commit comments

Comments
 (0)