Numpy 1.8 DeprecationWarning in compat/scipy.py · Issue #5824 · pandas-dev/pandas (original) (raw)

Not sure how pressing this is, but with DeprecationWarning enabled, I notice that numpy 1.8 is raising a warning during the following call to describe(). [side note: enabled DeprecationWarning in my test suite after learning that it was changed in py2.7 to "ignore" by default.]

import pandas as pd
import warnings
warnings.simplefilter("once", DeprecationWarning)

df = pd.DataFrame({"A": [1, 2, 3], "B": [1.2, 4.2, 5.2]})
print df.groupby('A')['B'].describe()
$ python test_fail.py 
.../pandas/compat/scipy.py:68: DeprecationWarning: using a non-integer
number instead of an integer will result in an error in the future
  score = values[idx]

Here's the full traceback with DeprecationWarning escalated to an error (warnings.simplefilter("error", DeprecationWarning)):

Traceback (most recent call last):
  File "test_fail.py", line 6, in <module>
    print df.groupby('A')['B'].describe()
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/groupby.py", line 343, in wrapper
    return self.apply(curried)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/groupby.py", line 424, in apply
    return self._python_apply_general(f)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/groupby.py", line 427, in _python_apply_general
    keys, values, mutated = self.grouper.apply(f, self.obj, self.axis)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/groupby.py", line 883, in apply
    res = f(group)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/groupby.py", line 422, in f
    return func(g, *args, **kwargs)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/groupby.py", line 329, in curried
    return f(x, *args, **kwargs)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/series.py", line 1386, in describe
    lb), self.median(), self.quantile(ub),
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/core/series.py", line 1316, in quantile
    result = _quantile(valid_values, q * 100)
  File "/home/gmd/ENV/pandas-master-2/lib/python2.7/site-packages/pandas-0.13.0_29_g97860a1-py2.7-linux-i686.egg/pandas/compat/scipy.py", line 68, in scoreatpercentile
    score = values[idx]
IndexError: cannot convert index to integer