Skip to content

BUG: Float64Index.get_value() for tuples. #14092

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1253,3 +1253,4 @@ Bug Fixes
- Bug in ``.to_string()`` when called with an integer ``line_width`` and ``index=False`` raises an UnboundLocalError exception because ``idx`` referenced before assignment.

- Bug in ``read_csv()``, where aliases for utf-xx (e.g. UTF-xx, UTF_xx, utf_xx) raised UnicodeDecodeError (:issue:`13549`)
- Bug in ``Float64Index.get_value()`` where trying to access one tuple-valued entry in a ``Series`` failed (:issue:`13509`)
10 changes: 1 addition & 9 deletions pandas/indexes/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,11 @@ def get_value(self, series, key):
if not is_scalar(key):
raise InvalidIndexError

from pandas.core.indexing import maybe_droplevels
from pandas.core.series import Series

k = _values_from_object(key)
loc = self.get_loc(k)
new_values = _values_from_object(series)[loc]

if is_scalar(new_values) or new_values is None:
return new_values

new_index = self[loc]
new_index = maybe_droplevels(new_index, k)
return Series(new_values, index=new_index, name=series.name)
return new_values

def equals(self, other):
"""
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/indexing/test_floats.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,3 +676,8 @@ def test_floating_misc(self):
assert_series_equal(result1, result2)
assert_series_equal(result1, result3)
assert_series_equal(result1, Series([1], index=[2.5]))

def test_floating_tuples(self):
s = Series([(1, 1), (2, 2), (3, 3)], index=[0.0, 0.1, 0.2])
result = s[0.0]
assert result == (1, 1)