@@ -508,7 +508,8 @@ def _validate_shift_value(self, fill_value):
508
508
)
509
509
fill_value = new_fill
510
510
511
- return self ._unbox (fill_value )
511
+ rv = self ._unbox (fill_value )
512
+ return self ._rebox_native (rv )
512
513
513
514
def _validate_scalar (self , value , msg : Optional [str ] = None ):
514
515
"""
@@ -603,18 +604,15 @@ def _validate_setitem_value(self, value):
603
604
else :
604
605
value = self ._validate_scalar (value , msg )
605
606
606
- return self ._unbox (value , setitem = True )
607
+ rv = self ._unbox (value , setitem = True )
608
+ return self ._rebox_native (rv )
607
609
608
610
def _validate_insert_value (self , value ):
609
611
msg = f"cannot insert { type (self ).__name__ } with incompatible label"
610
612
value = self ._validate_scalar (value , msg )
611
613
612
- self ._check_compatible_with (value , setitem = True )
613
- # TODO: if we dont have compat, should we raise or astype(object)?
614
- # PeriodIndex does astype(object)
615
- return value
616
- # Note: we do not unbox here because the caller needs boxed value
617
- # to check for freq.
614
+ rv = self ._unbox (value , setitem = True )
615
+ return self ._rebox_native (rv )
618
616
619
617
def _validate_where_value (self , other ):
620
618
msg = f"Where requires matching dtype, not { type (other )} "
@@ -623,7 +621,8 @@ def _validate_where_value(self, other):
623
621
else :
624
622
other = self ._validate_listlike (other )
625
623
626
- return self ._unbox (other , setitem = True )
624
+ rv = self ._unbox (other , setitem = True )
625
+ return self ._rebox_native (rv )
627
626
628
627
def _unbox (self , other , setitem : bool = False ) -> Union [np .int64 , np .ndarray ]:
629
628
"""
0 commit comments