.at and .iat indexing with Float64Index #8092

Closed
IanSudbery opened this Issue Aug 22, 2014 · 2 comments

Comments

Projects
None yet
3 participants

Using .at and .iat indexing with a Float64Index produces an error:

In [0]: import pandas as pd
In [1]: s = pd.Series([1,2,3], index = [0.1,0.2,0.3])
In [2]: s.at[0.1]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-a5888722fbca> in <module>()
----> 1 s.at[0.1]

/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/pandas/core/indexing.pyc in __getitem__(self, key)
   1264 
   1265         key = self._convert_key(key)
-> 1266         return self.obj.get_value(*key)
   1267 
   1268     def __setitem__(self, key, value):

/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/pandas/core/series.pyc in get_value(self, label)
    778         value : scalar value
    779         """
--> 780         return self.index.get_value(self.values, label)
    781 
    782     def set_value(self, label, value):

/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/pandas/core/index.pyc in get_value(self, series, key)
   1821         k = _values_from_object(key)
   1822         loc = self.get_loc(k)
-> 1823         new_values = series.values[loc]
   1824         if np.isscalar(new_values):
   1825             return new_values

AttributeError: 'numpy.ndarray' object has no attribute 'values'

In [3]: s.iat[1]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-db1ebf8cc8e6> in <module>()
----> 1 s.iat[1]

/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/pandas/core/indexing.pyc in __getitem__(self, key)
   1264 
   1265         key = self._convert_key(key)
-> 1266         return self.obj.get_value(*key)
   1267 
   1268     def __setitem__(self, key, value):

/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/pandas/core/series.pyc in get_value(self, label)
    778         value : scalar value
    779         """
--> 780         return self.index.get_value(self.values, label)
    781 
    782     def set_value(self, label, value):

/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/pandas/core/index.pyc in get_value(self, series, key)
   1821         k = _values_from_object(key)
   1822         loc = self.get_loc(k)
-> 1823         new_values = series.values[loc]
   1824         if np.isscalar(new_values):
   1825             return new_values

AttributeError: 'numpy.ndarray' object has no attribute 'values'

I'm not sure if this is intended behavoir. The docs only talk about [], loc, iloc and ix indexing with Float64Index, but if so, perhaps a more useful error message would be in order. I wasn't even aware my index was Float64. Its gotten changed at some point without me being aware of it.

Contributor

jreback commented Aug 22, 2014

yep, was not tested, so broken. work-around is .loc/.iloc

pull-requests welcome as well!

jreback added this to the 0.15.0 milestone Aug 22, 2014

Member

cpcloud commented Aug 22, 2014

pr coming

cpcloud self-assigned this Aug 22, 2014

cpcloud closed this in #8094 Aug 22, 2014

cpcloud was unassigned by wesm Oct 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment