We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent abb0936 commit 8a559cbCopy full SHA for 8a559cb
pandas/_libs/tslibs/period.pyx
@@ -32,7 +32,6 @@ from pandas._libs.tslibs.np_datetime cimport (
32
NPY_FR_D,
33
NPY_FR_us,
34
)
35
-from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
36
37
cdef extern from "src/datetime/np_datetime.h":
38
int64_t npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr,
@@ -2408,11 +2407,12 @@ class Period(_Period):
2408
2407
dt, reso = parse_time_string(value, freq)
2409
try:
2410
ts = Timestamp(value)
+ except ValueError:
2411
+ nanosecond = 0
2412
+ else:
2413
nanosecond = ts.nanosecond
2414
if nanosecond != 0:
2415
reso = 'nanosecond'
- except ValueError:
- nanosecond = 0
2416
if dt is NaT:
2417
ordinal = NPY_NAT
2418
0 commit comments