24
24
from pandas .core import generic
25
25
from pandas .core .construction import create_series_with_explicit_dtype
26
26
from pandas .core .generic import NDFrame
27
+ from pandas .core .indexes .api import Index
27
28
from pandas .core .reshape .concat import concat
28
29
29
30
from pandas .io .common import (
@@ -892,14 +893,19 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
892
893
if result :
893
894
return new_data , True
894
895
895
- result = False
896
+ result = True
896
897
897
898
if data .dtype == "object" :
898
-
899
+ if (
900
+ isinstance (data , Index )
901
+ and name == "index"
902
+ and self .orient == "split"
903
+ and len (data )
904
+ ):
905
+ result = False
899
906
# try float
900
907
try :
901
908
data = data .astype ("float64" )
902
- result = True
903
909
except (TypeError , ValueError ):
904
910
pass
905
911
@@ -910,7 +916,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
910
916
# coerce floats to 64
911
917
try :
912
918
data = data .astype ("float64" )
913
- result = True
914
919
except (TypeError , ValueError ):
915
920
pass
916
921
@@ -922,7 +927,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
922
927
new_data = data .astype ("int64" )
923
928
if (new_data == data ).all ():
924
929
data = new_data
925
- result = True
926
930
except (TypeError , ValueError , OverflowError ):
927
931
pass
928
932
@@ -932,7 +936,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
932
936
# coerce floats to 64
933
937
try :
934
938
data = data .astype ("int64" )
935
- result = True
936
939
except (TypeError , ValueError ):
937
940
pass
938
941
0 commit comments