19
19
from pandas .util ._decorators import deprecate_kwarg , deprecate_nonkeyword_arguments , doc
20
20
21
21
from pandas .core .dtypes .common import ensure_str , is_period_dtype
22
-
23
22
from pandas import DataFrame , MultiIndex , Series , isna , notna , to_datetime
24
23
from pandas .core import generic
25
24
from pandas .core .construction import create_series_with_explicit_dtype
26
25
from pandas .core .generic import NDFrame
26
+ from pandas .core .indexes .api import Index
27
27
from pandas .core .reshape .concat import concat
28
28
29
29
from pandas .io .common import (
@@ -892,14 +892,19 @@ 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 (
899
+ isinstance (data , Index )
900
+ and name == "index"
901
+ and self .orient == "split"
902
+ and len (data )
903
+ ):
904
+ result = False
899
905
# try float
900
906
try :
901
907
data = data .astype ("float64" )
902
- result = True
903
908
except (TypeError , ValueError ):
904
909
pass
905
910
@@ -910,7 +915,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
910
915
# coerce floats to 64
911
916
try :
912
917
data = data .astype ("float64" )
913
- result = True
914
918
except (TypeError , ValueError ):
915
919
pass
916
920
@@ -922,7 +926,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
922
926
new_data = data .astype ("int64" )
923
927
if (new_data == data ).all ():
924
928
data = new_data
925
- result = True
926
929
except (TypeError , ValueError , OverflowError ):
927
930
pass
928
931
@@ -932,7 +935,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
932
935
# coerce floats to 64
933
936
try :
934
937
data = data .astype ("int64" )
935
- result = True
936
938
except (TypeError , ValueError ):
937
939
pass
938
940
0 commit comments