@@ -1190,8 +1190,8 @@ def _try_convert_data(
1190
1190
return data , False
1191
1191
1192
1192
if convert_dates :
1193
- new_data , result = self ._try_convert_to_date (data )
1194
- if result :
1193
+ new_data = self ._try_convert_to_date (data )
1194
+ if new_data is not data :
1195
1195
return new_data , True
1196
1196
1197
1197
converted = False
@@ -1241,7 +1241,7 @@ def _try_convert_data(
1241
1241
return data , converted
1242
1242
1243
1243
@final
1244
- def _try_convert_to_date (self , data : Series ) -> tuple [ Series , bool ] :
1244
+ def _try_convert_to_date (self , data : Series ) -> Series :
1245
1245
"""
1246
1246
Try to parse a ndarray like into a date column.
1247
1247
@@ -1250,7 +1250,7 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
1250
1250
"""
1251
1251
# no conversion on empty
1252
1252
if not len (data ):
1253
- return data , False
1253
+ return data
1254
1254
1255
1255
new_data = data
1256
1256
@@ -1261,7 +1261,7 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
1261
1261
try :
1262
1262
new_data = data .astype ("int64" )
1263
1263
except OverflowError :
1264
- return data , False
1264
+ return data
1265
1265
except (TypeError , ValueError ):
1266
1266
pass
1267
1267
@@ -1273,16 +1273,15 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
1273
1273
| (new_data ._values == iNaT )
1274
1274
)
1275
1275
if not in_range .all ():
1276
- return data , False
1276
+ return data
1277
1277
1278
1278
date_units = (self .date_unit ,) if self .date_unit else self ._STAMP_UNITS
1279
1279
for date_unit in date_units :
1280
1280
try :
1281
- new_data = to_datetime (new_data , errors = "raise" , unit = date_unit )
1281
+ return to_datetime (new_data , errors = "raise" , unit = date_unit )
1282
1282
except (ValueError , OverflowError , TypeError ):
1283
1283
continue
1284
- return new_data , True
1285
- return data , False
1284
+ return data
1286
1285
1287
1286
1288
1287
class SeriesParser (Parser ):
0 commit comments