-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame._get_value not working for IntervalIndex #27927
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
Comments
I will give a try |
cc @jschendel i ran into this recently, too. any idea what it would take to implement IntervalTree.get_value? |
I think That being said, it looks like adding diff --git a/pandas/core/frame.py b/pandas/core/frame.py
index 676b78573..30bda9775 100644
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -2898,7 +2898,7 @@ class DataFrame(NDFrame):
if self.index.nlevels > 1:
# partial indexing forbidden
raise
- except (TypeError, ValueError):
+ except (AttributeError, TypeError, ValueError):
pass
# we cannot handle direct indexing With the diff applied: In [2]: df = pd.DataFrame(
...: np.arange(9).reshape(3,3),
...: columns=list('ABC'),
...: index=pd.interval_range(0, 3)
...: )
In [3]: df
Out[3]:
A B C
(0, 1] 0 1 2
(1, 2] 3 4 5
(2, 3] 6 7 8
In [4]: df.at[df.index[0], 'A']
Out[4]: 0
In [5]: df.at[df.index[1], 'B']
Out[5]: 4
In [6]: df.at[0.5, 'C']
Out[6]: 2 |
Would the issue be resolved if instead of calling index._engine.get_value we used index.get_value? |
closed by #41846 |
Follow-up on #27926 and #27865
DataFrame._get_value
with an IntervalIndex is not working properly:This
_get_value
is used inix
which is deprecated, but also inat
which is not deprecated:The text was updated successfully, but these errors were encountered: