Skip to content

Commit 5e9db38

Browse files
committed
Merge pull request #3591 from jreback/groupby_period_index
BUG: fix take platorm issue with PeriodIndex (GH3579)
2 parents 56da2b2 + bc3e432 commit 5e9db38

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

RELEASE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pandas 0.11.1
103103
- Fix ``.diff`` on datelike and timedelta operations (GH3100_)
104104
- ``combine_first`` not returning the same dtype in cases where it can (GH3552_)
105105
- Fixed bug with ``Panel.transpose`` argument aliases (GH3556_)
106+
- Fixed platform bug in ``PeriodIndex.take`` (GH3579_)
106107
- Fixed bug in reset_index with ``NaN`` in a multi-index (GH3586_)
107108

108109
.. _GH3164: https://github.com/pydata/pandas/issues/3164
@@ -143,6 +144,7 @@ pandas 0.11.1
143144
.. _GH3562: https://github.com/pydata/pandas/issues/3562
144145
.. _GH3586: https://github.com/pydata/pandas/issues/3586
145146
.. _GH3493: https://github.com/pydata/pandas/issues/3493
147+
.. _GH3579: https://github.com/pydata/pandas/issues/3579
146148
.. _GH3556: https://github.com/pydata/pandas/issues/3556
147149

148150

pandas/tests/test_groupby.py

+9
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@ def test_agg_period_index(self):
318318
rs = df.groupby(level=0).sum()
319319
self.assert_(isinstance(rs.index, PeriodIndex))
320320

321+
# GH 3579
322+
index = period_range(start='1999-01', periods=5, freq='M')
323+
s1 = Series(np.random.rand(len(index)), index=index)
324+
s2 = Series(np.random.rand(len(index)), index=index)
325+
series = [('s1', s1), ('s2',s2)]
326+
df = DataFrame.from_items(series)
327+
grouped = df.groupby(df.index.month)
328+
list(grouped)
329+
321330
def test_agg_must_agg(self):
322331
grouped = self.df.groupby('A')['C']
323332
self.assertRaises(Exception, grouped.agg, lambda x: x.describe())

pandas/tseries/period.py

+1
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ def take(self, indices, axis=None):
11251125
"""
11261126
Analogous to ndarray.take
11271127
"""
1128+
indices = com._ensure_platform_int(indices)
11281129
taken = self.values.take(indices, axis=axis)
11291130
taken = taken.view(PeriodIndex)
11301131
taken.freq = self.freq

0 commit comments

Comments
 (0)