@@ -6299,27 +6299,18 @@ def ensure_index(index_like: AnyArrayLike | Sequence, copy: bool = False) -> Ind
6299
6299
if copy :
6300
6300
index_like = index_like .copy ()
6301
6301
return index_like
6302
- if hasattr (index_like , "name" ):
6303
- # https://github.com/python/mypy/issues/1424
6304
- # error: Item "ExtensionArray" of "Union[ExtensionArray,
6305
- # Sequence[Any]]" has no attribute "name"
6306
- # error: Item "Sequence[Any]" of "Union[ExtensionArray, Sequence[Any]]"
6307
- # has no attribute "name"
6308
- # error: "Sequence[Any]" has no attribute "name"
6309
- # error: Item "Sequence[Any]" of "Union[Series, Sequence[Any]]" has no
6310
- # attribute "name"
6311
- # error: Item "Sequence[Any]" of "Union[Any, Sequence[Any]]" has no
6312
- # attribute "name"
6313
- name = index_like .name # type: ignore[union-attr, attr-defined]
6302
+
6303
+ if isinstance (index_like , ABCSeries ):
6304
+ name = index_like .name
6314
6305
return Index (index_like , name = name , copy = copy )
6315
6306
6316
6307
if is_iterator (index_like ):
6317
6308
index_like = list (index_like )
6318
6309
6319
- # must check for exactly list here because of strict type
6320
- # check in clean_index_list
6321
6310
if isinstance (index_like , list ):
6322
- if type (index_like ) != list :
6311
+ if type (index_like ) is not list :
6312
+ # must check for exactly list here because of strict type
6313
+ # check in clean_index_list
6323
6314
index_like = list (index_like )
6324
6315
6325
6316
converted , all_arrays = lib .clean_index_list (index_like )
@@ -6329,13 +6320,6 @@ def ensure_index(index_like: AnyArrayLike | Sequence, copy: bool = False) -> Ind
6329
6320
6330
6321
return MultiIndex .from_arrays (converted )
6331
6322
else :
6332
- if isinstance (converted , np .ndarray ) and converted .dtype == np .int64 :
6333
- # Check for overflows if we should actually be uint64
6334
- # xref GH#35481
6335
- alt = np .asarray (index_like )
6336
- if alt .dtype == np .uint64 :
6337
- converted = alt
6338
-
6339
6323
index_like = converted
6340
6324
else :
6341
6325
# clean_index_list does the equivalent of copying
0 commit comments