Skip to content

Commit

Permalink
post-merge fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Nov 26, 2023
1 parent 43f17dc commit 610b2b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/strptime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def array_strptime(
ival, tz, ambiguous="raise", nonexistent=None, creso=creso
)
nsecs = (ival - iresult[i])
if creso == NPY_FR_ns:
if creso == NPY_DATETIMEUNIT.NPY_FR_ns:
nsecs = nsecs // 10**9
elif creso == NPY_DATETIMEUNIT.NPY_FR_us:
nsecs = nsecs // 10**6
Expand Down Expand Up @@ -880,7 +880,7 @@ def _array_strptime_object_fallback(
result[i] = ts
continue

if parse_today_now(val, &iresult, utc, NPY_FR_ns):
if parse_today_now(val, &iresult, utc, NPY_DATETIMEUNIT.NPY_FR_ns):
result[i] = Timestamp(val)
continue

Expand Down
6 changes: 4 additions & 2 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,15 @@ def _array_strptime_with_fallback(
"""
result, tz_out = array_strptime(arg, fmt, exact=exact, errors=errors, utc=utc)
if tz_out is not None:
dtype = DatetimeTZDtype(tz=tz_out)
unit = np.datetime_data(result.dtype)[0]
dtype = DatetimeTZDtype(tz=tz_out, unit=unit)
dta = DatetimeArray._simple_new(result, dtype=dtype)
if utc:
dta = dta.tz_convert("UTC")
return Index(dta, name=name)
elif result.dtype != object and utc:
res = Index(result, dtype="M8[ns, UTC]", name=name)
unit = np.datetime_data(result.dtype)[0]
res = Index(result, dtype=f"M8[{unit}, UTC]", name=name)
return res
return Index(result, dtype=result.dtype, name=name)

Expand Down

0 comments on commit 610b2b1

Please sign in to comment.