GroupBy with Float Index not Plotting · Issue #7025 · pandas-dev/pandas (original) (raw)

I have the following problem: I have a dataset with a float index that I want to group and plot. If I'm using integer indices it works, with floats it doesn't. Here is the minimal example that once works and once not. I'm testing with the current master. Am I doing something wrong?

This code snippet fails:

import pandas as pd
import numpy as np
test = pd.DataFrame({'def': [1,1,1,2,2,2,3,3,3], 'val': np.random.randn(9)}, index=[1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0])
test.groupby('def')['val'].plot()

While this works:

# This Works
test = pd.DataFrame({'def': [1,1,1,2,2,2,3,3,3], 'val': np.random.randn(9)}, index= [1,2,3,1,2,3,1,2,3])
test.groupby('def')['val'].plot()

The error I get is:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-83-e50f1a9b07c6> in <module>()
----> 1 test.groupby('def')['val'].plot()

/Library/Python/2.7/site-packages/pandas-0.13.1_758_g4a67608-py2.7-macosx-10.9-intel.egg/pandas/core/groupby.pyc in __getattr__(self, attr)
    452         if attr in self._internal_names_set:
    453             return object.__getattribute__(self, attr)
--> 454         if attr in self.obj:
    455             return self[attr]
    456 

/Library/Python/2.7/site-packages/pandas-0.13.1_758_g4a67608-py2.7-macosx-10.9-intel.egg/pandas/core/series.pyc in __contains__(self, key)
    379 
    380     def __contains__(self, key):
--> 381         return key in self.index
    382 
    383     # complex

/Library/Python/2.7/site-packages/pandas-0.13.1_758_g4a67608-py2.7-macosx-10.9-intel.egg/pandas/core/index.pyc in __contains__(self, other)
   2042         try:
   2043             # if other is a sequence this throws a ValueError
-> 2044             return np.isnan(other) and self._hasnans
   2045         except ValueError:
   2046             try:

NotImplementedError: Not implemented for this type