Repository: pandas-dev/pandas

Issue:
idxmax() not available on groupby anymore
Just saw an example in this [SO question](http://stackoverflow.com/questions/18879782/python-pandas-groupby-forloop-idxmax), the use of `idxmax()` on a groupby object:

```
df.groupby(...).idxmax()
```

This worked in 0.12, but not anymore in 0.13 as it is not in the whitelist.
- Should this be added to the whitelist? (idxmax/idxmin for SeriesGroupby) I think this is a usefull method on a groupby object.
- I got an AttributeError and not a DeprecationWarning. There was spoken of a deprecation first (#5480), but was it decided not to do it? 



Discussion:
you can add to whitelist
no depreciation warning anymore because u also need to maintain a blacklist which makes maintaining this even harder

FYI

you can always do

df.groupby(...).apply(lambda x: x.idxmax())

@jreback I know, but for idxmax I think this is usefull enough to have to shortcut available. Plus, this will break existing code (as the example on SO shows that it is used).

And I was just about to open an new issue about this, because it seems the `apply` also does not work the same as in 0.12. With example from this SO (http://stackoverflow.com/questions/20819702/hourly-frequency-count-with-python/20820166#20820166), and with 0.13rc, this:

```
df.groupby(df.index.date).apply(lambda x: x.idxmax())
```

generates a

```
ValueError: Shape of passed values is (1, 3), indices imply (1, 3)
```

while in 0.12 it does work.

It has to do I think with difference between SeriesGroupby and DataFrameGroupby with one column, as `df.groupby(df.index.date)['value'].apply(lambda x: x.idxmax())` does work in master, but in 0.12 both ways work.

ok go ahead and do a or for adding idxmax/min to whitelist (and in the test for same)

I'll look at the apply issue

can u open the apply as a separate issue with a small example
thanks (so close this one with a pr for adding idxmax/min to whitelist)


Resolving patch:
diff --git a/pandas/core/groupby.py b/pandas/core/groupby.py
--- a/pandas/core/groupby.py
+++ b/pandas/core/groupby.py
@@ -65,6 +65,7 @@
     'mad',
     'any', 'all',
     'irow', 'take',
+    'idxmax', 'idxmin',
     'shift', 'tshift',
     'ffill', 'bfill',
     'pct_change', 'skew',


Test patch:
diff --git a/pandas/tests/test_groupby.py b/pandas/tests/test_groupby.py
--- a/pandas/tests/test_groupby.py
+++ b/pandas/tests/test_groupby.py
@@ -3264,6 +3264,7 @@ def test_groupby_whitelist(self):
             'mad',
             'any', 'all',
             'irow', 'take',
+            'idxmax', 'idxmin',
             'shift', 'tshift',
             'ffill', 'bfill',
             'pct_change', 'skew',
@@ -3284,6 +3285,7 @@ def test_groupby_whitelist(self):
             'mad',
             'any', 'all',
             'irow', 'take',
+            'idxmax', 'idxmin',
             'shift', 'tshift',
             'ffill', 'bfill',
             'pct_change', 'skew',
@@ -3413,7 +3415,7 @@ def test_tab_completion(self):
             'resample', 'cummin', 'fillna', 'cumsum', 'cumcount',
             'all', 'shift', 'skew', 'bfill', 'irow', 'ffill',
             'take', 'tshift', 'pct_change', 'any', 'mad', 'corr', 'corrwith',
-            'cov', 'dtypes', 'diff',
+            'cov', 'dtypes', 'diff', 'idxmax', 'idxmin'
         ])
         self.assertEqual(results, expected)