Skip to content

BUG: DataFrame._get_value not working for IntervalIndex #27927

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

Follow-up on #27926 and #27865

DataFrame._get_value with an IntervalIndex is not working properly:

In [24]:         df = DataFrame( 
    ...:             np.random.randn(5, 2), 
    ...:             columns=["a", "b"], 
    ...:             index=pd.IntervalIndex.from_breaks([-np.inf, 0, 1, 2, 3, np.inf]), 
    ...:         )  

In [26]: df._get_value(df.index[0], 'a')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-26-ce242a095ada> in <module>
----> 1 df._get_value(df.index[0], 'a')

~/scipy/pandas/pandas/core/frame.py in _get_value(self, index, col, takeable)
   2953 
   2954         try:
-> 2955             return engine.get_value(series._values, index)
   2956         except KeyError:
   2957             # GH 20629

AttributeError: 'pandas._libs.interval.IntervalTree' object has no attribute 'get_value'

This _get_value is used in ix which is deprecated, but also in at which is not deprecated:

In [27]: df.at[df.index[0], 'a']
...
AttributeError: 'pandas._libs.interval.IntervalTree' object has no attribute 'get_value'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesIntervalInterval data type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions