diff --git a/RELEASE.rst b/RELEASE.rst index 82a0e85b7df2c..e470ebaa96804 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -110,6 +110,11 @@ pandas 0.6.2 - Handle all NA case in Series.corr, was raising exception (GH #548) - Aggregating by multiple levels with ``level`` argument to DataFrame, Series stat method, was broken (GH #545) + - Fix Cython buf when converter passed to read_csv produced a numeric array + (buffer dtype mismatch when passed to Cython type inference function) (GH + #546) + - Fix exception when setting scalar value using .ix on a DataFrame with a + MultiIndex (GH #551) Thanks ------ diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 29809060f5469..35446454f5304 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -211,6 +211,12 @@ def _convert_to_indexer(self, obj, axis=0): - No, prefer label-based indexing """ index = self.obj._get_axis(axis) + + try: + return index.get_loc(obj) + except (KeyError, TypeError): + pass + is_int_index = _is_integer_index(index) if isinstance(obj, slice): if _is_label_slice(index, obj): diff --git a/pandas/tests/test_multilevel.py b/pandas/tests/test_multilevel.py index e63b583eee017..340fae8c99fe2 100644 --- a/pandas/tests/test_multilevel.py +++ b/pandas/tests/test_multilevel.py @@ -290,6 +290,16 @@ def test_setitem_change_dtype(self): reindexed = dft.reindex(columns=[('foo', 'two')]) assert_series_equal(reindexed['foo', 'two'], s > s.median()) + def test_frame_setitem_ix(self): + self.frame.ix[('bar', 'two'), 'B'] = 5 + self.assertEquals(self.frame.ix[('bar', 'two'), 'B'], 5) + + # with integer labels + df = self.frame.copy() + df.columns = range(3) + df.ix[('bar', 'two'), 1] = 7 + self.assertEquals(df.ix[('bar', 'two'), 1], 7) + def test_fancy_slice_partial(self): result = self.frame.ix['bar':'baz'] expected = self.frame[3:7]