@@ -593,7 +593,7 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"):
593
593
594
594
# use native type formatting for datetime/tz/timedelta
595
595
if self .is_datelike :
596
- values = self .to_native_types ()
596
+ values = self .to_native_types (). values
597
597
598
598
# astype formatting
599
599
else :
@@ -684,7 +684,7 @@ def to_native_types(self, na_rep="nan", quoting=None, **kwargs):
684
684
values = np .array (values , dtype = "object" )
685
685
686
686
values [mask ] = na_rep
687
- return values
687
+ return self . make_block ( values )
688
688
689
689
# block actions #
690
690
def copy (self , deep : bool = True ):
@@ -1774,7 +1774,7 @@ def to_native_types(self, na_rep="nan", quoting=None, **kwargs):
1774
1774
1775
1775
# TODO(EA2D): reshape not needed with 2D EAs
1776
1776
# we are expected to return a 2-d ndarray
1777
- return values . reshape ( 1 , len ( values ) )
1777
+ return self . make_block ( values )
1778
1778
1779
1779
def take_nd (
1780
1780
self , indexer , axis : int = 0 , new_mgr_locs = None , fill_value = lib .no_default
@@ -2021,7 +2021,7 @@ def to_native_types(
2021
2021
values = np .array (values , dtype = "object" )
2022
2022
2023
2023
values [mask ] = na_rep
2024
- return values
2024
+ return self . make_block ( values )
2025
2025
2026
2026
from pandas .io .formats .format import FloatArrayFormatter
2027
2027
@@ -2033,7 +2033,8 @@ def to_native_types(
2033
2033
quoting = quoting ,
2034
2034
fixed_width = False ,
2035
2035
)
2036
- return formatter .get_result_as_array ()
2036
+ res = formatter .get_result_as_array ()
2037
+ return self .make_block (res )
2037
2038
2038
2039
2039
2040
class ComplexBlock (FloatOrComplexBlock ):
@@ -2192,7 +2193,7 @@ def to_native_types(self, na_rep="NaT", date_format=None, **kwargs):
2192
2193
result = dta ._format_native_types (
2193
2194
na_rep = na_rep , date_format = date_format , ** kwargs
2194
2195
)
2195
- return np . atleast_2d (result )
2196
+ return self . make_block (result )
2196
2197
2197
2198
def set (self , locs , values ):
2198
2199
"""
@@ -2408,7 +2409,8 @@ def fillna(self, value, **kwargs):
2408
2409
def to_native_types (self , na_rep = "NaT" , ** kwargs ):
2409
2410
""" convert to our native types format """
2410
2411
tda = self .array_values ()
2411
- return tda ._format_native_types (na_rep , ** kwargs )
2412
+ res = tda ._format_native_types (na_rep , ** kwargs )
2413
+ return self .make_block (res )
2412
2414
2413
2415
2414
2416
class BoolBlock (NumericBlock ):
0 commit comments