@@ -160,24 +160,18 @@ def ensure_int_or_float(arr: ArrayLike, copy: bool = False) -> ArrayLike:
160
160
will remain unchanged.
161
161
"""
162
162
# TODO: GH27506 potential bug with ExtensionArrays
163
- def call_right_astype (arr : ArrayLike , inttype : str ) -> ArrayLike :
164
- if isinstance (arr , np .ndarray ):
165
- return arr .astype (inttype , copy = copy , casting = "safe" )
166
- else :
167
- return arr .astype (inttype , copy = copy )
168
-
169
- try :
170
- return call_right_astype (arr , "int64" )
171
- except TypeError :
172
- pass
173
- try :
174
- return call_right_astype (arr , "uint64" )
175
- except TypeError :
176
- if is_extension_array_dtype (arr .dtype ):
177
- return cast ("ExtensionArray" , arr ).to_numpy (
178
- dtype = "float64" , na_value = np .nan
179
- )
180
- return arr .astype ("float64" , copy = copy )
163
+ if is_extension_array_dtype (arr .dtype ):
164
+ return cast ("ExtensionArray" , arr ).to_numpy (dtype = "float64" , na_value = np .nan )
165
+ else :
166
+ assert isinstance (arr , np .ndarray ) # For typing
167
+ try :
168
+ return arr .astype ("int64" , copy = copy , casting = "safe" )
169
+ except TypeError :
170
+ pass
171
+ try :
172
+ return arr .astype ("uint64" , copy = copy , casting = "safe" )
173
+ except TypeError :
174
+ return arr .astype ("float64" , copy = copy )
181
175
182
176
183
177
def ensure_python_int (value : Union [int , np .integer ]) -> int :
0 commit comments