File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1015,8 +1015,11 @@ def _setitem_copy(self, copy):
10151015 self ._is_copy = copy
10161016 return self
10171017
1018- def _check_setitem_copy (self ):
1019- """ validate if we are doing a settitem on a chained copy """
1018+ def _check_setitem_copy (self , stacklevel = 4 ):
1019+ """ validate if we are doing a settitem on a chained copy.
1020+
1021+ If you call this function, be sure to set the stacklevel such that the
1022+ user will see the error *at the level of setting*"""
10201023 if self ._is_copy :
10211024 value = config .get_option ('mode.chained_assignment' )
10221025
@@ -1026,7 +1029,7 @@ def _check_setitem_copy(self):
10261029 if value == 'raise' :
10271030 raise SettingWithCopyError (t )
10281031 elif value == 'warn' :
1029- warnings .warn (t , SettingWithCopyWarning )
1032+ warnings .warn (t , SettingWithCopyWarning , stacklevel = stacklevel )
10301033
10311034 def __delitem__ (self , key ):
10321035 """
You can’t perform that action at this time.
0 commit comments