From 9e4a379f56ea95c2cd84d15a26285dfc44c168a6 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Mon, 17 Jun 2019 22:42:12 +0100 Subject: [PATCH 01/11] Raise a ValueError when index and data lengths don't match --- pandas/core/indexing.py | 3 +++ pandas/tests/indexing/test_iloc.py | 13 +++++++++++++ pandas/tests/indexing/test_loc.py | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 7f4827be6dff7..73a2f077f9b37 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1441,6 +1441,9 @@ def _getbool_axis(self, key, axis=None): axis = self.axis or 0 labels = self.obj._get_axis(axis) key = check_bool_indexer(labels, key) + if 0 < len(labels) != len(key): + raise ValueError('Item wrong length %d instead of %d.' % + (len(key), len(labels))) inds, = key.nonzero() try: return self.obj._take(inds, axis=axis) diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 4fa26dc67ba0c..d9c0720576ce2 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -265,6 +265,19 @@ def test_iloc_getitem_bool(self): typs=['labels', 'mixed', 'ts', 'floats', 'empty'], fails=IndexError) + def test_iloc_getitem_bool_diff_len(self): + # GH26658 + too_short = [True, False] + too_long = [True, False, True, False, False] + self.check_result('bool', 'iloc', too_short, 'ix', too_short, + typs=['ints', 'uints', 'labels', + 'mixed', 'ts', 'floats'], + fails=ValueError) + self.check_result('bool', 'iloc', too_long, 'ix', too_long, + typs=['ints', 'uints', 'labels', + 'mixed', 'ts', 'floats'], + fails=ValueError) + def test_iloc_getitem_slice(self): # slices diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 5f5718fe3eac3..05379b02bdce9 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -196,6 +196,19 @@ def test_loc_getitem_bool(self): self.check_result('bool', 'loc', b, 'ix', b, typs=['empty'], fails=KeyError) + def test_loc_getitem_bool_diff_len(self): + # GH26658 + too_short = [True, False] + too_long = [True, False, True, False, False] + self.check_result('bool', 'loc', too_short, 'ix', too_short, + typs=['ints', 'uints', 'labels', + 'mixed', 'ts', 'floats'], + fails=ValueError) + self.check_result('bool', 'loc', too_long, 'ix', too_long, + typs=['ints', 'uints', 'labels', + 'mixed', 'ts', 'floats'], + fails=ValueError) + def test_loc_getitem_int_slice(self): # ok From 14c7461ed852c912bd23259133c37d9562192a47 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Mon, 17 Jun 2019 22:59:40 +0100 Subject: [PATCH 02/11] Add whatsnew entry --- doc/source/whatsnew/v0.25.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 2b1a61186dca6..d4a6f2b3ffc56 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -630,6 +630,7 @@ Indexing - Improved exception message when calling :meth:`DataFrame.iloc` with a list of non-numeric objects (:issue:`25753`). - Bug in :meth:`DataFrame.loc` and :meth:`Series.loc` where ``KeyError`` was not raised for a ``MultiIndex`` when the key was less than or equal to the number of levels in the :class:`MultiIndex` (:issue:`14885`). +- Bug in ``.iloc`` and ``.loc`` where ``ValueError`` was not raised for a boolean index with different length (:issue:`26658`). - Bug in which :meth:`DataFrame.append` produced an erroneous warning indicating that a ``KeyError`` will be thrown in the future when the data to be appended contains new columns (:issue:`22252`). - Bug in which :meth:`DataFrame.to_csv` caused a segfault for a reindexed data frame, when the indices were single-level :class:`MultiIndex` (:issue:`26303`). - Fixed bug where assigning a :class:`arrays.PandasArray` to a :class:`pandas.core.frame.DataFrame` would raise error (:issue:`26390`) From ff237649f742e21ed8ec8fc6063494413611a726 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Wed, 19 Jun 2019 18:53:35 +0100 Subject: [PATCH 03/11] Move section raising error into check_bool_indexer, adjust tests --- pandas/core/indexing.py | 46 ++++++++++++++++++++------ pandas/tests/indexing/test_iloc.py | 23 ++++++------- pandas/tests/indexing/test_indexing.py | 14 +++----- pandas/tests/indexing/test_loc.py | 19 +++++------ 4 files changed, 59 insertions(+), 43 deletions(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 73a2f077f9b37..7498eedb93c0e 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1441,9 +1441,6 @@ def _getbool_axis(self, key, axis=None): axis = self.axis or 0 labels = self.obj._get_axis(axis) key = check_bool_indexer(labels, key) - if 0 < len(labels) != len(key): - raise ValueError('Item wrong length %d instead of %d.' % - (len(key), len(labels))) inds, = key.nonzero() try: return self.obj._take(inds, axis=axis) @@ -2409,20 +2406,43 @@ def convert_to_index_sliceable(obj, key): return None -def check_bool_indexer(ax, key): - # boolean indexing, need to check that the data are aligned, otherwise - # disallowed +def check_bool_indexer(index, key): + """ + Check if key is a valid boolean indexer for an object with such index and + perform reindexing or conversion if needed. + + This function assumes that is_bool_indexer(key) == True. + + Parameters + ---------- + key : list-like + Boolean indexer to check + + index : Index + Index of the object on which the indexing is done - # this function assumes that is_bool_indexer(key) == True + Returns + ------- + result: np.array + Resulting key + Raises + ------ + ValueError + If the key does not have the same length as index + + IndexingError + If the index of the key is unalignable to index + + """ result = key - if isinstance(key, ABCSeries) and not key.index.equals(ax): - result = result.reindex(ax) + if isinstance(key, ABCSeries) and not key.index.equals(index): + result = result.reindex(index) mask = isna(result._values) if mask.any(): raise IndexingError('Unalignable boolean Series provided as ' 'indexer (index of the boolean Series and of ' - 'the indexed object do not match') + 'the indexed object do not match).') result = result.astype(bool)._values elif is_sparse(result): result = result.to_dense() @@ -2430,6 +2450,12 @@ def check_bool_indexer(ax, key): else: # is_bool_indexer has already checked for nulls in the case of an # object array key, so no check needed here + + # GH26658 + if all([len(i) > 0 for i in (index, key)]) and len(index) != len(key): + raise ValueError( + 'Item wrong length {} instead of {}.'.format(len(key), + len(index))) result = np.asarray(result, dtype=bool) return result diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index d9c0720576ce2..fe344d0a0e65e 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -265,18 +265,15 @@ def test_iloc_getitem_bool(self): typs=['labels', 'mixed', 'ts', 'floats', 'empty'], fails=IndexError) - def test_iloc_getitem_bool_diff_len(self): + @pytest.mark.parametrize('index', [[True, False], + [True, False, True, False]]) + def test_iloc_getitem_bool_diff_len(self, index): # GH26658 - too_short = [True, False] - too_long = [True, False, True, False, False] - self.check_result('bool', 'iloc', too_short, 'ix', too_short, - typs=['ints', 'uints', 'labels', - 'mixed', 'ts', 'floats'], - fails=ValueError) - self.check_result('bool', 'iloc', too_long, 'ix', too_long, - typs=['ints', 'uints', 'labels', - 'mixed', 'ts', 'floats'], - fails=ValueError) + s = Series([1, 2, 3]) + with pytest.raises(ValueError, + match=('Item wrong length {} instead of {}.'.format( + len(index), len(s)))): + _ = s.iloc[index] def test_iloc_getitem_slice(self): @@ -627,10 +624,10 @@ def test_iloc_mask(self): 'cannot use an indexable as a mask'), ('locs', ''): 'Unalignable boolean Series provided as indexer ' '(index of the boolean Series and of the indexed ' - 'object do not match', + 'object do not match).', ('locs', '.loc'): 'Unalignable boolean Series provided as indexer ' '(index of the boolean Series and of the ' - 'indexed object do not match', + 'indexed object do not match).', ('locs', '.iloc'): ('iLocation based boolean indexing on an ' 'integer type is not available'), } diff --git a/pandas/tests/indexing/test_indexing.py b/pandas/tests/indexing/test_indexing.py index a0e3df182b129..749234f20b092 100644 --- a/pandas/tests/indexing/test_indexing.py +++ b/pandas/tests/indexing/test_indexing.py @@ -1107,24 +1107,20 @@ def test_extension_array_cross_section_converts(): tm.assert_series_equal(result, expected) -@pytest.mark.parametrize('idxr, error, error_message', [ +@pytest.mark.parametrize('idxr, error_message', [ (lambda x: x, - AttributeError, "'numpy.ndarray' object has no attribute 'get'"), (lambda x: x.loc, - AttributeError, "type object 'NDFrame' has no attribute '_AXIS_ALIASES'"), (lambda x: x.iloc, - AttributeError, "type object 'NDFrame' has no attribute '_AXIS_ALIASES'"), pytest.param( lambda x: x.ix, - ValueError, - "NDFrameIndexer does not support NDFrame objects with ndim > 2", + "type object 'NDFrame' has no attribute '_AXIS_ALIASES'", marks=ignore_ix) ]) -def test_ndframe_indexing_raises(idxr, error, error_message): +def test_ndframe_indexing_raises(idxr, error_message): # GH 25567 frame = NDFrame(np.random.randint(5, size=(2, 2, 2))) - with pytest.raises(error, match=error_message): - idxr(frame)[0] + with pytest.raises(AttributeError, match=error_message): + _ = idxr(frame)[0] diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 05379b02bdce9..d0422b0b5e340 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -196,18 +196,15 @@ def test_loc_getitem_bool(self): self.check_result('bool', 'loc', b, 'ix', b, typs=['empty'], fails=KeyError) - def test_loc_getitem_bool_diff_len(self): + @pytest.mark.parametrize('index', [[True, False], + [True, False, True, False]]) + def test_loc_getitem_bool_diff_len(self, index): # GH26658 - too_short = [True, False] - too_long = [True, False, True, False, False] - self.check_result('bool', 'loc', too_short, 'ix', too_short, - typs=['ints', 'uints', 'labels', - 'mixed', 'ts', 'floats'], - fails=ValueError) - self.check_result('bool', 'loc', too_long, 'ix', too_long, - typs=['ints', 'uints', 'labels', - 'mixed', 'ts', 'floats'], - fails=ValueError) + s = Series([1, 2, 3]) + with pytest.raises(ValueError, + match=('Item wrong length {} instead of {}.'.format( + len(index), len(s)))): + _ = s.loc[index] def test_loc_getitem_int_slice(self): From 7e43bf44bde0c94ae748d8f0676951a527cc58e2 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Wed, 19 Jun 2019 19:42:06 +0100 Subject: [PATCH 04/11] Revert test_indexing to previous version --- pandas/tests/indexing/test_indexing.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pandas/tests/indexing/test_indexing.py b/pandas/tests/indexing/test_indexing.py index 749234f20b092..a0e3df182b129 100644 --- a/pandas/tests/indexing/test_indexing.py +++ b/pandas/tests/indexing/test_indexing.py @@ -1107,20 +1107,24 @@ def test_extension_array_cross_section_converts(): tm.assert_series_equal(result, expected) -@pytest.mark.parametrize('idxr, error_message', [ +@pytest.mark.parametrize('idxr, error, error_message', [ (lambda x: x, + AttributeError, "'numpy.ndarray' object has no attribute 'get'"), (lambda x: x.loc, + AttributeError, "type object 'NDFrame' has no attribute '_AXIS_ALIASES'"), (lambda x: x.iloc, + AttributeError, "type object 'NDFrame' has no attribute '_AXIS_ALIASES'"), pytest.param( lambda x: x.ix, - "type object 'NDFrame' has no attribute '_AXIS_ALIASES'", + ValueError, + "NDFrameIndexer does not support NDFrame objects with ndim > 2", marks=ignore_ix) ]) -def test_ndframe_indexing_raises(idxr, error_message): +def test_ndframe_indexing_raises(idxr, error, error_message): # GH 25567 frame = NDFrame(np.random.randint(5, size=(2, 2, 2))) - with pytest.raises(AttributeError, match=error_message): - _ = idxr(frame)[0] + with pytest.raises(error, match=error_message): + idxr(frame)[0] From 3138b46159f9ef45c7ea4532208aaa9e0bc97025 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Wed, 19 Jun 2019 20:24:17 +0100 Subject: [PATCH 05/11] Remove unnecessary list comprehension from core/indexing.py --- pandas/core/indexing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 7498eedb93c0e..7526dedefa97c 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -2452,7 +2452,7 @@ def check_bool_indexer(index, key): # object array key, so no check needed here # GH26658 - if all([len(i) > 0 for i in (index, key)]) and len(index) != len(key): + if all((len(i) > 0 for i in (index, key))) and len(index) != len(key): raise ValueError( 'Item wrong length {} instead of {}.'.format(len(key), len(index))) From 3624ecbbdda2facc44f0a389bde2d662ac1ef015 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Fri, 21 Jun 2019 10:09:54 +0100 Subject: [PATCH 06/11] Add type annotations, simplify condition --- pandas/core/indexing.py | 14 +++++++------- pandas/tests/indexing/test_iloc.py | 5 ++++- pandas/tests/indexing/test_loc.py | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 7526dedefa97c..3819fae472a11 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1,4 +1,5 @@ import textwrap +from typing import Sequence import warnings import numpy as np @@ -2406,7 +2407,7 @@ def convert_to_index_sliceable(obj, key): return None -def check_bool_indexer(index, key): +def check_bool_indexer(index: Index, key: Sequence[bool]) -> np.ndarray: """ Check if key is a valid boolean indexer for an object with such index and perform reindexing or conversion if needed. @@ -2415,11 +2416,10 @@ def check_bool_indexer(index, key): Parameters ---------- - key : list-like - Boolean indexer to check - index : Index Index of the object on which the indexing is done + key : list-like + Boolean indexer to check Returns ------- @@ -2450,13 +2450,13 @@ def check_bool_indexer(index, key): else: # is_bool_indexer has already checked for nulls in the case of an # object array key, so no check needed here + result = np.asarray(result, dtype=bool) # GH26658 - if all((len(i) > 0 for i in (index, key))) and len(index) != len(key): + if len(result) != len(index): raise ValueError( - 'Item wrong length {} instead of {}.'.format(len(key), + 'Item wrong length {} instead of {}.'.format(len(result), len(index))) - result = np.asarray(result, dtype=bool) return result diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index fe344d0a0e65e..5297ce7c25a5b 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -262,8 +262,11 @@ def test_iloc_getitem_bool(self): b = [True, False, True, False, ] self.check_result('bool', 'iloc', b, 'ix', b, typs=['ints', 'uints']) self.check_result('bool', 'iloc', b, 'ix', b, - typs=['labels', 'mixed', 'ts', 'floats', 'empty'], + typs=['labels', 'mixed', 'ts', 'floats'], fails=IndexError) + self.check_result('bool', 'iloc', b, 'ix', b, + typs=['empty'], + fails=ValueError) @pytest.mark.parametrize('index', [[True, False], [True, False, True, False]]) diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index d0422b0b5e340..0bf99e4165f49 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -194,7 +194,7 @@ def test_loc_getitem_bool(self): typs=['ints', 'uints', 'labels', 'mixed', 'ts', 'floats']) self.check_result('bool', 'loc', b, 'ix', b, typs=['empty'], - fails=KeyError) + fails=ValueError) @pytest.mark.parametrize('index', [[True, False], [True, False, True, False]]) From 578c53755ed19267f5f4679da21a3be01ae5d34b Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Fri, 21 Jun 2019 10:57:27 +0100 Subject: [PATCH 07/11] Remove incorrect type annotation --- pandas/core/indexing.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 84b22aca1cb34..59443ec37edab 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1,5 +1,4 @@ import textwrap -from typing import Sequence import warnings import numpy as np @@ -2408,7 +2407,7 @@ def convert_to_index_sliceable(obj, key): return None -def check_bool_indexer(index: Index, key: Sequence[bool]) -> np.ndarray: +def check_bool_indexer(index: Index, key) -> np.ndarray: """ Check if key is a valid boolean indexer for an object with such index and perform reindexing or conversion if needed. From 71b4e4e46f52db8991aa0495dd8e22fb280c94bc Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Fri, 21 Jun 2019 14:07:56 +0100 Subject: [PATCH 08/11] Change order, simplify condition --- pandas/core/indexing.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 59443ec37edab..cdd21216ee755 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -2444,12 +2444,9 @@ def check_bool_indexer(index: Index, key) -> np.ndarray: 'indexer (index of the boolean Series and of ' 'the indexed object do not match).') result = result.astype(bool)._values - elif is_sparse(result): - result = result.to_dense() - result = np.asarray(result, dtype=bool) else: - # is_bool_indexer has already checked for nulls in the case of an - # object array key, so no check needed here + if is_sparse(result): + result = result.to_dense() result = np.asarray(result, dtype=bool) # GH26658 From 8340642c599afc8834d9fd2232496b7c0f56a4c2 Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Sun, 23 Jun 2019 14:37:38 +0100 Subject: [PATCH 09/11] Change ValueError to IndexError --- pandas/core/indexing.py | 4 ++-- pandas/tests/indexing/test_iloc.py | 7 ++----- pandas/tests/indexing/test_loc.py | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index cdd21216ee755..f63ebfad572a4 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -2428,7 +2428,7 @@ def check_bool_indexer(index: Index, key) -> np.ndarray: Raises ------ - ValueError + IndexError If the key does not have the same length as index IndexingError @@ -2451,7 +2451,7 @@ def check_bool_indexer(index: Index, key) -> np.ndarray: # GH26658 if len(result) != len(index): - raise ValueError( + raise IndexError( 'Item wrong length {} instead of {}.'.format(len(result), len(index))) diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 5297ce7c25a5b..14a8f2b9f8914 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -262,18 +262,15 @@ def test_iloc_getitem_bool(self): b = [True, False, True, False, ] self.check_result('bool', 'iloc', b, 'ix', b, typs=['ints', 'uints']) self.check_result('bool', 'iloc', b, 'ix', b, - typs=['labels', 'mixed', 'ts', 'floats'], + typs=['labels', 'mixed', 'ts', 'floats', 'empty'], fails=IndexError) - self.check_result('bool', 'iloc', b, 'ix', b, - typs=['empty'], - fails=ValueError) @pytest.mark.parametrize('index', [[True, False], [True, False, True, False]]) def test_iloc_getitem_bool_diff_len(self, index): # GH26658 s = Series([1, 2, 3]) - with pytest.raises(ValueError, + with pytest.raises(IndexError, match=('Item wrong length {} instead of {}.'.format( len(index), len(s)))): _ = s.iloc[index] diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 0bf99e4165f49..2035a96faafc9 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -194,14 +194,14 @@ def test_loc_getitem_bool(self): typs=['ints', 'uints', 'labels', 'mixed', 'ts', 'floats']) self.check_result('bool', 'loc', b, 'ix', b, typs=['empty'], - fails=ValueError) + fails=IndexError) @pytest.mark.parametrize('index', [[True, False], [True, False, True, False]]) def test_loc_getitem_bool_diff_len(self, index): # GH26658 s = Series([1, 2, 3]) - with pytest.raises(ValueError, + with pytest.raises(IndexError, match=('Item wrong length {} instead of {}.'.format( len(index), len(s)))): _ = s.loc[index] From 46dcf278d2b09e902bca89d8f984c558afdbe21d Mon Sep 17 00:00:00 2001 From: krsnik93 Date: Mon, 24 Jun 2019 16:11:34 +0100 Subject: [PATCH 10/11] Change whatsnew --- doc/source/whatsnew/v0.25.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index b9816dd19578a..7895d3a80d1b3 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -665,8 +665,8 @@ Indexing ^^^^^^^^ - Improved exception message when calling :meth:`DataFrame.iloc` with a list of non-numeric objects (:issue:`25753`). +- Improved exception message when calling ``.iloc`` or ``.loc`` with a boolean indexer with different length (:issue:`26658`). - Bug in :meth:`DataFrame.loc` and :meth:`Series.loc` where ``KeyError`` was not raised for a ``MultiIndex`` when the key was less than or equal to the number of levels in the :class:`MultiIndex` (:issue:`14885`). -- Bug in ``.iloc`` and ``.loc`` where ``ValueError`` was not raised for a boolean index with different length (:issue:`26658`). - Bug in which :meth:`DataFrame.append` produced an erroneous warning indicating that a ``KeyError`` will be thrown in the future when the data to be appended contains new columns (:issue:`22252`). - Bug in which :meth:`DataFrame.to_csv` caused a segfault for a reindexed data frame, when the indices were single-level :class:`MultiIndex` (:issue:`26303`). - Fixed bug where assigning a :class:`arrays.PandasArray` to a :class:`pandas.core.frame.DataFrame` would raise error (:issue:`26390`) From 4f819c38a726f90fde6d301d578d05ad2343a743 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 26 Jun 2019 08:11:59 -0500 Subject: [PATCH 11/11] update release note --- doc/source/whatsnew/v0.25.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index c4318a5cc87d2..901e4f6942897 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -674,6 +674,7 @@ Indexing - Improved exception message when calling :meth:`DataFrame.iloc` with a list of non-numeric objects (:issue:`25753`). - Improved exception message when calling ``.iloc`` or ``.loc`` with a boolean indexer with different length (:issue:`26658`). +- Bug in ``.iloc`` and ``.loc`` with a boolean indexer not raising an ``IndexError`` when too few items are passed (:issue:`26658`). - Bug in :meth:`DataFrame.loc` and :meth:`Series.loc` where ``KeyError`` was not raised for a ``MultiIndex`` when the key was less than or equal to the number of levels in the :class:`MultiIndex` (:issue:`14885`). - Bug in which :meth:`DataFrame.append` produced an erroneous warning indicating that a ``KeyError`` will be thrown in the future when the data to be appended contains new columns (:issue:`22252`). - Bug in which :meth:`DataFrame.to_csv` caused a segfault for a reindexed data frame, when the indices were single-level :class:`MultiIndex` (:issue:`26303`).