@@ -74,7 +74,7 @@ def arrays_to_mgr(arrays, arr_names, index, columns, dtype=None):
74
74
return create_block_manager_from_arrays (arrays , arr_names , axes )
75
75
76
76
77
- def masked_rec_array_to_mgr (data , index , columns , dtype , copy ):
77
+ def masked_rec_array_to_mgr (data , index , columns , dtype , copy : bool ):
78
78
"""
79
79
Extract from a masked rec array and create the manager.
80
80
"""
@@ -143,7 +143,7 @@ def init_ndarray(values, index, columns, dtype=None, copy=False):
143
143
):
144
144
145
145
if not hasattr (values , "dtype" ):
146
- values = prep_ndarray (values , copy = copy )
146
+ values = _prep_ndarray (values , copy = copy )
147
147
values = values .ravel ()
148
148
elif copy :
149
149
values = values .copy ()
@@ -166,7 +166,7 @@ def init_ndarray(values, index, columns, dtype=None, copy=False):
166
166
167
167
# by definition an array here
168
168
# the dtypes will be coerced to a single dtype
169
- values = prep_ndarray (values , copy = copy )
169
+ values = _prep_ndarray (values , copy = copy )
170
170
171
171
if dtype is not None :
172
172
if not is_dtype_equal (values .dtype , dtype ):
@@ -257,7 +257,7 @@ def init_dict(data, index, columns, dtype=None):
257
257
# ---------------------------------------------------------------------
258
258
259
259
260
- def prep_ndarray (values , copy = True ) -> np .ndarray :
260
+ def _prep_ndarray (values , copy : bool = True ) -> np .ndarray :
261
261
if not isinstance (values , (np .ndarray , ABCSeries , Index )):
262
262
if len (values ) == 0 :
263
263
return np .empty ((0 , 0 ), dtype = object )
@@ -598,29 +598,24 @@ def convert(arr):
598
598
# Series-Based
599
599
600
600
601
- def sanitize_index (data , index , copy = False ):
601
+ def sanitize_index (data , index : Index ):
602
602
"""
603
603
Sanitize an index type to return an ndarray of the underlying, pass
604
604
through a non-Index.
605
605
"""
606
606
607
- if index is None :
608
- return data
609
-
610
607
if len (data ) != len (index ):
611
608
raise ValueError ("Length of values does not match length of index" )
612
609
613
- if isinstance (data , ABCIndexClass ) and not copy :
610
+ if isinstance (data , ABCIndexClass ):
614
611
pass
615
612
elif isinstance (data , (ABCPeriodIndex , ABCDatetimeIndex )):
616
613
data = data ._values
617
- if copy :
618
- data = data .copy ()
619
614
620
615
elif isinstance (data , np .ndarray ):
621
616
622
617
# coerce datetimelike types
623
618
if data .dtype .kind in ["M" , "m" ]:
624
- data = sanitize_array (data , index , copy = copy )
619
+ data = sanitize_array (data , index , copy = False )
625
620
626
621
return data
0 commit comments