Skip to content

Commit 1abb61c

Browse files
committed
Remove extra bool return
1 parent 7059407 commit 1abb61c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pandas/io/json/_json.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,8 @@ def _try_convert_data(
11901190
return data, False
11911191

11921192
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:
11951195
return new_data, True
11961196

11971197
converted = False
@@ -1241,7 +1241,7 @@ def _try_convert_data(
12411241
return data, converted
12421242

12431243
@final
1244-
def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
1244+
def _try_convert_to_date(self, data: Series) -> Series:
12451245
"""
12461246
Try to parse a ndarray like into a date column.
12471247
@@ -1250,7 +1250,7 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
12501250
"""
12511251
# no conversion on empty
12521252
if not len(data):
1253-
return data, False
1253+
return data
12541254

12551255
new_data = data
12561256

@@ -1261,7 +1261,7 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
12611261
try:
12621262
new_data = data.astype("int64")
12631263
except OverflowError:
1264-
return data, False
1264+
return data
12651265
except (TypeError, ValueError):
12661266
pass
12671267

@@ -1273,16 +1273,15 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]:
12731273
| (new_data._values == iNaT)
12741274
)
12751275
if not in_range.all():
1276-
return data, False
1276+
return data
12771277

12781278
date_units = (self.date_unit,) if self.date_unit else self._STAMP_UNITS
12791279
for date_unit in date_units:
12801280
try:
1281-
new_data = to_datetime(new_data, errors="raise", unit=date_unit)
1281+
return to_datetime(new_data, errors="raise", unit=date_unit)
12821282
except (ValueError, OverflowError, TypeError):
12831283
continue
1284-
return new_data, True
1285-
return data, False
1284+
return data
12861285

12871286

12881287
class SeriesParser(Parser):

0 commit comments

Comments
 (0)