1818from pandas .errors import AbstractMethodError
1919from pandas .util ._decorators import deprecate_kwarg , deprecate_nonkeyword_arguments , doc
2020
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
2323from pandas import DataFrame , MultiIndex , Series , isna , notna , to_datetime
2424from pandas .core import generic
2525from 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):
892892 if result :
893893 return new_data , True
894894
895- result = False
895+ result = True
896896
897897 if data .dtype == "object" :
898-
898+ if isinstance (data , Index ) and name == 'index' and self .orient == 'split' and len (data ):
899+ result = False
899900 # try float
900901 try :
901902 data = data .astype ("float64" )
902- result = True
903903 except (TypeError , ValueError ):
904904 pass
905905
@@ -910,7 +910,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
910910 # coerce floats to 64
911911 try :
912912 data = data .astype ("float64" )
913- result = True
914913 except (TypeError , ValueError ):
915914 pass
916915
@@ -922,7 +921,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
922921 new_data = data .astype ("int64" )
923922 if (new_data == data ).all ():
924923 data = new_data
925- result = True
926924 except (TypeError , ValueError , OverflowError ):
927925 pass
928926
@@ -932,7 +930,6 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
932930 # coerce floats to 64
933931 try :
934932 data = data .astype ("int64" )
935- result = True
936933 except (TypeError , ValueError ):
937934 pass
938935
0 commit comments