Skip to content

Commit 8a559cb

Browse files
author
OlivierLuG
committed
pandas-dev#34621 Added nanosecond support to Period constructor
1 parent abb0936 commit 8a559cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/_libs/tslibs/period.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ from pandas._libs.tslibs.np_datetime cimport (
3232
NPY_FR_D,
3333
NPY_FR_us,
3434
)
35-
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
3635

3736
cdef extern from "src/datetime/np_datetime.h":
3837
int64_t npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr,
@@ -2408,11 +2407,12 @@ class Period(_Period):
24082407
dt, reso = parse_time_string(value, freq)
24092408
try:
24102409
ts = Timestamp(value)
2410+
except ValueError:
2411+
nanosecond = 0
2412+
else:
24112413
nanosecond = ts.nanosecond
24122414
if nanosecond != 0:
24132415
reso = 'nanosecond'
2414-
except ValueError:
2415-
nanosecond = 0
24162416
if dt is NaT:
24172417
ordinal = NPY_NAT
24182418

0 commit comments

Comments
 (0)