From 0b3c53e0dbc49462c17bd1e46e08d1cbd60fc9d2 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Fri, 22 Aug 2014 10:02:05 -0400 Subject: [PATCH] BUG: fix iat and at for Float64Index --- doc/source/v0.15.0.txt | 3 ++- pandas/core/index.py | 3 ++- pandas/tests/test_indexing.py | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/source/v0.15.0.txt b/doc/source/v0.15.0.txt index ac475d637f9cf..4a39dd73da7d0 100644 --- a/doc/source/v0.15.0.txt +++ b/doc/source/v0.15.0.txt @@ -634,7 +634,8 @@ Bug Fixes - +- Bug in ``Float64Index`` where ``iat`` and ``at`` were not testing and were + failing (:issue:`8092`). diff --git a/pandas/core/index.py b/pandas/core/index.py index 4bfeb86cd84c0..505b557fc0d85 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -2309,7 +2309,8 @@ def get_value(self, series, key): k = _values_from_object(key) loc = self.get_loc(k) - new_values = series.values[loc] + new_values = _values_from_object(series)[loc] + if np.isscalar(new_values) or new_values is None: return new_values diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py index 967f437fc5ca1..daeef9b78b037 100644 --- a/pandas/tests/test_indexing.py +++ b/pandas/tests/test_indexing.py @@ -3818,6 +3818,13 @@ def test_float_index_non_scalar_assignment(self): df.loc[df.index] = df.loc[df.index] tm.assert_frame_equal(df,df2) + def test_float_index_at_iat(self): + s = pd.Series([1, 2, 3], index=[0.1, 0.2, 0.3]) + for el, item in s.iteritems(): + self.assertEqual(s.at[el], item) + for i in range(len(s)): + self.assertEqual(s.iat[i], i + 1) + class TestSeriesNoneCoercion(tm.TestCase): EXPECTED_RESULTS = [