|
28 | 28 | get_unit_from_dtype,
|
29 | 29 | iNaT,
|
30 | 30 | is_supported_unit,
|
31 |
| - nat_strings, |
32 |
| - parsing, |
33 | 31 | timezones as libtimezones,
|
34 | 32 | )
|
35 | 33 | from pandas._libs.tslibs.conversion import precision_from_unit
|
|
42 | 40 | AnyArrayLike,
|
43 | 41 | ArrayLike,
|
44 | 42 | DateTimeErrorChoices,
|
45 |
| - npt, |
46 | 43 | )
|
47 | 44 | from pandas.util._exceptions import find_stack_level
|
48 | 45 |
|
|
62 | 59 | ABCDataFrame,
|
63 | 60 | ABCSeries,
|
64 | 61 | )
|
65 |
| -from pandas.core.dtypes.missing import notna |
66 | 62 |
|
67 | 63 | from pandas.arrays import (
|
68 | 64 | DatetimeArray,
|
69 | 65 | IntegerArray,
|
70 | 66 | NumpyExtensionArray,
|
71 | 67 | )
|
72 |
| -from pandas.core import algorithms |
73 | 68 | from pandas.core.algorithms import unique
|
74 | 69 | from pandas.core.arrays import ArrowExtensionArray
|
75 | 70 | from pandas.core.arrays.base import ExtensionArray
|
@@ -1273,58 +1268,6 @@ def coerce(values):
|
1273 | 1268 | return values
|
1274 | 1269 |
|
1275 | 1270 |
|
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 |
| - |
1328 | 1271 | __all__ = [
|
1329 | 1272 | "DateParseError",
|
1330 | 1273 | "should_cache",
|
|
0 commit comments