Skip to content

.at and .iat indexing with Float64Index #8092

Closed
@IanSudbery

Description

@IanSudbery

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions