Skip to content

Commit 625d8d6

Browse files
authored
CLN: remove unused in tools.datetimes (#55652)
1 parent 03a4981 commit 625d8d6

File tree

3 files changed

+0
-81
lines changed

3 files changed

+0
-81
lines changed

pandas/_libs/tslibs/parsing.pyi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ def try_parse_dates(
2323
values: npt.NDArray[np.object_], # object[:]
2424
parser,
2525
) -> npt.NDArray[np.object_]: ...
26-
def try_parse_year_month_day(
27-
years: npt.NDArray[np.object_], # object[:]
28-
months: npt.NDArray[np.object_], # object[:]
29-
days: npt.NDArray[np.object_], # object[:]
30-
) -> npt.NDArray[np.object_]: ...
3126
def guess_datetime_format(
3227
dt_str,
3328
dayfirst: bool | None = ...,

pandas/_libs/tslibs/parsing.pyx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -766,25 +766,6 @@ def try_parse_dates(object[:] values, parser) -> np.ndarray:
766766
return result.base # .base to access underlying ndarray
767767

768768

769-
def try_parse_year_month_day(
770-
object[:] years, object[:] months, object[:] days
771-
) -> np.ndarray:
772-
cdef:
773-
Py_ssize_t i, n
774-
object[::1] result
775-
776-
n = len(years)
777-
# TODO(cython3): Use len instead of `shape[0]`
778-
if months.shape[0] != n or days.shape[0] != n:
779-
raise ValueError("Length of years/months/days must all be equal")
780-
result = np.empty(n, dtype="O")
781-
782-
for i in range(n):
783-
result[i] = datetime(int(years[i]), int(months[i]), int(days[i]))
784-
785-
return result.base # .base to access underlying ndarray
786-
787-
788769
# ----------------------------------------------------------------------
789770
# Miscellaneous
790771

pandas/core/tools/datetimes.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
get_unit_from_dtype,
2929
iNaT,
3030
is_supported_unit,
31-
nat_strings,
32-
parsing,
3331
timezones as libtimezones,
3432
)
3533
from pandas._libs.tslibs.conversion import precision_from_unit
@@ -42,7 +40,6 @@
4240
AnyArrayLike,
4341
ArrayLike,
4442
DateTimeErrorChoices,
45-
npt,
4643
)
4744
from pandas.util._exceptions import find_stack_level
4845

@@ -62,14 +59,12 @@
6259
ABCDataFrame,
6360
ABCSeries,
6461
)
65-
from pandas.core.dtypes.missing import notna
6662

6763
from pandas.arrays import (
6864
DatetimeArray,
6965
IntegerArray,
7066
NumpyExtensionArray,
7167
)
72-
from pandas.core import algorithms
7368
from pandas.core.algorithms import unique
7469
from pandas.core.arrays import ArrowExtensionArray
7570
from pandas.core.arrays.base import ExtensionArray
@@ -1273,58 +1268,6 @@ def coerce(values):
12731268
return values
12741269

12751270

1276-
def _attempt_YYYYMMDD(arg: npt.NDArray[np.object_], errors: str) -> np.ndarray | None:
1277-
"""
1278-
try to parse the YYYYMMDD/%Y%m%d format, try to deal with NaT-like,
1279-
arg is a passed in as an object dtype, but could really be ints/strings
1280-
with nan-like/or floats (e.g. with nan)
1281-
1282-
Parameters
1283-
----------
1284-
arg : np.ndarray[object]
1285-
errors : {'raise','ignore','coerce'}
1286-
"""
1287-
1288-
def calc(carg):
1289-
# calculate the actual result
1290-
carg = carg.astype(object, copy=False)
1291-
parsed = parsing.try_parse_year_month_day(
1292-
carg / 10000, carg / 100 % 100, carg % 100
1293-
)
1294-
return tslib.array_to_datetime(parsed, errors=errors)[0]
1295-
1296-
def calc_with_mask(carg, mask):
1297-
result = np.empty(carg.shape, dtype="M8[ns]")
1298-
iresult = result.view("i8")
1299-
iresult[~mask] = iNaT
1300-
1301-
masked_result = calc(carg[mask].astype(np.float64).astype(np.int64))
1302-
result[mask] = masked_result.astype("M8[ns]")
1303-
return result
1304-
1305-
# try intlike / strings that are ints
1306-
try:
1307-
return calc(arg.astype(np.int64))
1308-
except (ValueError, OverflowError, TypeError):
1309-
pass
1310-
1311-
# a float with actual np.nan
1312-
try:
1313-
carg = arg.astype(np.float64)
1314-
return calc_with_mask(carg, notna(carg))
1315-
except (ValueError, OverflowError, TypeError):
1316-
pass
1317-
1318-
# string with NaN-like
1319-
try:
1320-
mask = ~algorithms.isin(arg, list(nat_strings))
1321-
return calc_with_mask(arg, mask)
1322-
except (ValueError, OverflowError, TypeError):
1323-
pass
1324-
1325-
return None
1326-
1327-
13281271
__all__ = [
13291272
"DateParseError",
13301273
"should_cache",

0 commit comments

Comments
 (0)