From 3ddb1a5ee0f9e56ab0cc37a4ab956b4829c0abb1 Mon Sep 17 00:00:00 2001 From: agodbug Date: Wed, 17 Aug 2022 15:55:27 +0800 Subject: [PATCH] Update frame.py fix a bug of at indexer: when using df.at[slice, item] = array for existed item it will raise the pandas.errors.InvalidIndexError --- pandas/core/frame.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index fcd822988de20..b22f93d488de2 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -198,6 +198,7 @@ nargsort, ) +from pandas.errors import InvalidIndexError from pandas.io.common import get_handle from pandas.io.formats import ( console, @@ -3872,7 +3873,7 @@ def _set_value( # or ValueError series._mgr.setitem_inplace(loc, value) - except (KeyError, TypeError, ValueError): + except (KeyError, TypeError, ValueError, InvalidIndexError): # set using a non-recursive method & reset the cache if takeable: self.iloc[index, col] = value