Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.at and .iat indexing with Float64Index #8092

Closed
IanSudbery opened this issue Aug 22, 2014 · 2 comments · Fixed by #8094
Closed

.at and .iat indexing with Float64Index #8092

IanSudbery opened this issue Aug 22, 2014 · 2 comments · Fixed by #8094
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@IanSudbery
Copy link

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.

@jreback
Copy link
Contributor

jreback commented Aug 22, 2014

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

pull-requests welcome as well!

@jreback jreback added this to the 0.15.0 milestone Aug 22, 2014
@cpcloud
Copy link
Member

cpcloud commented Aug 22, 2014

pr coming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants