@@ -598,7 +598,7 @@ def setitem(self, indexer, value) -> Self:
598598 return self
599599 # No need to split if we either set all columns or on a single block
600600 # manager
601- self = self .copy ()
601+ self = self .copy (deep = True )
602602
603603 return self .apply ("setitem" , indexer = indexer , value = value )
604604
@@ -712,30 +712,21 @@ def _combine(self, blocks: list[Block], index: Index | None = None) -> Self:
712712 def nblocks (self ) -> int :
713713 return len (self .blocks )
714714
715- def copy (self , deep : bool | Literal [ "all" ] = True ) -> Self :
715+ def copy (self , * , deep : bool ) -> Self :
716716 """
717717 Make deep or shallow copy of BlockManager
718718
719719 Parameters
720720 ----------
721721 deep : bool, string or None, default True
722- If False or None, return a shallow copy (do not copy data)
723- If 'all', copy data and a deep copy of the index
722+ If False, return a shallow copy (do not copy data)
724723
725724 Returns
726725 -------
727726 BlockManager
728727 """
729- # this preserves the notion of view copying of axes
730- if deep :
731- # hit in e.g. tests.io.json.test_pandas
732-
733- def copy_func (ax ):
734- return ax .copy (deep = True ) if deep == "all" else ax .view ()
735-
736- new_axes = [copy_func (ax ) for ax in self .axes ]
737- else :
738- new_axes = [ax .view () for ax in self .axes ]
728+ # TODO: Should deep=True be respected for axes?
729+ new_axes = [ax .view () for ax in self .axes ]
739730
740731 res = self .apply ("copy" , deep = deep )
741732 res .axes = new_axes
@@ -2188,7 +2179,7 @@ def setitem_inplace(self, indexer, value) -> None:
21882179 the dtype.
21892180 """
21902181 if not self ._has_no_reference (0 ):
2191- self .blocks = (self ._block .copy (),)
2182+ self .blocks = (self ._block .copy (deep = True ),)
21922183 self ._reset_cache ()
21932184
21942185 arr = self .array
0 commit comments