18
18
from pandas .errors import AbstractMethodError
19
19
from pandas .util ._decorators import deprecate_kwarg , deprecate_nonkeyword_arguments , doc
20
20
21
- from pandas .core .dtypes .common import ensure_str , is_period_dtype
22
-
21
+ from pandas .core .dtypes .common import ensure_str , is_period_dtype , is_string_like_dtype
22
+ from pandas . core . indexes . api import Index
23
23
from pandas import DataFrame , MultiIndex , Series , isna , notna , to_datetime
24
24
from pandas .core import generic
25
25
from pandas .core .construction import create_series_with_explicit_dtype
@@ -892,14 +892,14 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
892
892
if result :
893
893
return new_data , True
894
894
895
- result = False
895
+ result = True
896
896
897
897
if data .dtype == "object" :
898
-
898
+ if isinstance (data , Index ) and name == 'index' and self .orient == 'split' and len (data ):
899
+ result = False
899
900
# try float
900
901
try :
901
902
data = data .astype ("float64" )
902
- result = True
903
903
except (TypeError , ValueError ):
904
904
pass
905
905
@@ -910,7 +910,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
910
910
# coerce floats to 64
911
911
try :
912
912
data = data .astype ("float64" )
913
- result = True
914
913
except (TypeError , ValueError ):
915
914
pass
916
915
@@ -922,7 +921,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
922
921
new_data = data .astype ("int64" )
923
922
if (new_data == data ).all ():
924
923
data = new_data
925
- result = True
926
924
except (TypeError , ValueError , OverflowError ):
927
925
pass
928
926
@@ -932,7 +930,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
932
930
# coerce floats to 64
933
931
try :
934
932
data = data .astype ("int64" )
935
- result = True
936
933
except (TypeError , ValueError ):
937
934
pass
938
935
0 commit comments