Skip to content

BUG?: .at not working on object indexes containing some integers #19860

Closed
@c-thiel

Description

@c-thiel

Version 0.22.0

Problem description

Using the .at - Method on an Index which contains Integers as well as str/objects raises an Error. This used to be possible using the .get_value()-Method. As .at is the designated successor (#15269) the same behaviour should be supported.
I also noticed that .get_value is approx. twice as fast as .at. Is there a specific reason to stick with .at? (see again #15269 for a speed comparison)

Code Sample

import pandas as pd
import numpy as np

data = np.random.randn(10, 5)
df = pd.DataFrame(data, columns=['a', 'b', 'c', 1, 2])
df.at[0, 1]

Raises:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/thielc/anaconda3/lib/python3.6/site-packages/pandas/core/indexing.py", line 1868, in __getitem__
    key = self._convert_key(key)
  File "/home/thielc/anaconda3/lib/python3.6/site-packages/pandas/core/indexing.py", line 1915, in _convert_key
    raise ValueError("At based indexing on an non-integer "
ValueError: At based indexing on an non-integer index can only have non-integer indexers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype 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