Skip to content

BUG: fix take platorm issue with PeriodIndex (GH3579) #3591

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

Merged
merged 1 commit into from
May 13, 2013
Merged
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
2 changes: 2 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pandas 0.11.1
- Fix ``.diff`` on datelike and timedelta operations (GH3100_)
- ``combine_first`` not returning the same dtype in cases where it can (GH3552_)
- Fixed bug with ``Panel.transpose`` argument aliases (GH3556_)
- Fixed platform bug in ``PeriodIndex.take`` (GH3579_)
- Fixed bug in reset_index with ``NaN`` in a multi-index (GH3586_)

.. _GH3164: https://github.com/pydata/pandas/issues/3164
Expand Down Expand Up @@ -143,6 +144,7 @@ pandas 0.11.1
.. _GH3562: https://github.com/pydata/pandas/issues/3562
.. _GH3586: https://github.com/pydata/pandas/issues/3586
.. _GH3493: https://github.com/pydata/pandas/issues/3493
.. _GH3579: https://github.com/pydata/pandas/issues/3579
.. _GH3556: https://github.com/pydata/pandas/issues/3556


Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ def test_agg_period_index(self):
rs = df.groupby(level=0).sum()
self.assert_(isinstance(rs.index, PeriodIndex))

# GH 3579
index = period_range(start='1999-01', periods=5, freq='M')
s1 = Series(np.random.rand(len(index)), index=index)
s2 = Series(np.random.rand(len(index)), index=index)
series = [('s1', s1), ('s2',s2)]
df = DataFrame.from_items(series)
grouped = df.groupby(df.index.month)
list(grouped)

def test_agg_must_agg(self):
grouped = self.df.groupby('A')['C']
self.assertRaises(Exception, grouped.agg, lambda x: x.describe())
Expand Down
1 change: 1 addition & 0 deletions pandas/tseries/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ def take(self, indices, axis=None):
"""
Analogous to ndarray.take
"""
indices = com._ensure_platform_int(indices)
taken = self.values.take(indices, axis=axis)
taken = taken.view(PeriodIndex)
taken.freq = self.freq
Expand Down