-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Description
The except? -1 can be removed
pandas/pandas/_libs/tslibs/np_datetime.pyx
Lines 274 to 283 in e2598a1
| cdef int string_to_dts( | |
| str val, | |
| npy_datetimestruct* dts, | |
| NPY_DATETIMEUNIT* out_bestunit, | |
| int* out_local, | |
| int* out_tzoffset, | |
| bint want_exc, | |
| format: str | None=None, | |
| bint exact=True, | |
| ) except? -1: |
as string_to_dts is only ever called with want_exc=False
This function would need amending to raise ValueError if string_to_dts failed
Lines 79 to 100 in 502919e
| def _test_parse_iso8601(ts: str): | |
| """ | |
| TESTING ONLY: Parse string into Timestamp using iso8601 parser. Used | |
| only for testing, actual construction uses `convert_str_to_tsobject` | |
| """ | |
| cdef: | |
| _TSObject obj | |
| int out_local = 0, out_tzoffset = 0 | |
| NPY_DATETIMEUNIT out_bestunit | |
| obj = _TSObject() | |
| string_to_dts(ts, &obj.dts, &out_bestunit, &out_local, &out_tzoffset, True) | |
| obj.value = npy_datetimestruct_to_datetime(NPY_FR_ns, &obj.dts) | |
| check_dts_bounds(&obj.dts) | |
| if out_local == 1: | |
| obj.tzinfo = timezone(timedelta(minutes=out_tzoffset)) | |
| obj.value = tz_localize_to_utc_single(obj.value, obj.tzinfo) | |
| return Timestamp(obj.value, tz=obj.tzinfo) | |
| else: | |
| return Timestamp(obj.value) | |