2424from pandas .core import generic
2525from pandas .core .construction import create_series_with_explicit_dtype
2626from pandas .core .generic import NDFrame
27+ from pandas .core .indexes .api import Index
2728from pandas .core .reshape .concat import concat
2829
2930from pandas .io .common import (
@@ -892,14 +893,19 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
892893 if result :
893894 return new_data , True
894895
895- result = False
896+ result = True
896897
897898 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
899906 # try float
900907 try :
901908 data = data .astype ("float64" )
902- result = True
903909 except (TypeError , ValueError ):
904910 pass
905911
@@ -910,7 +916,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
910916 # coerce floats to 64
911917 try :
912918 data = data .astype ("float64" )
913- result = True
914919 except (TypeError , ValueError ):
915920 pass
916921
@@ -922,7 +927,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
922927 new_data = data .astype ("int64" )
923928 if (new_data == data ).all ():
924929 data = new_data
925- result = True
926930 except (TypeError , ValueError , OverflowError ):
927931 pass
928932
@@ -932,7 +936,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
932936 # coerce floats to 64
933937 try :
934938 data = data .astype ("int64" )
935- result = True
936939 except (TypeError , ValueError ):
937940 pass
938941
0 commit comments