@@ -1445,6 +1445,10 @@ def extract_ordinals(object[:] values, freq):
1445
1445
1446
1446
freqstr = Period._maybe_convert_freq(freq).freqstr
1447
1447
1448
+ from pandas.core.config import get_option
1449
+ dayfirst = get_option(' display.date_dayfirst' )
1450
+ yearfirst = get_option(' display.date_yearfirst' )
1451
+
1448
1452
for i in range (n):
1449
1453
p = values[i]
1450
1454
@@ -1459,7 +1463,8 @@ def extract_ordinals(object[:] values, freq):
1459
1463
raise IncompatibleFrequency(msg)
1460
1464
1461
1465
except AttributeError :
1462
- p = Period(p, freq = freq)
1466
+ p = Period(p, freq = freq, dayfirst = dayfirst,
1467
+ yearfirst = yearfirst)
1463
1468
if p is NaT:
1464
1469
# input may contain NaT-like string
1465
1470
ordinals[i] = NPY_NAT
@@ -2397,11 +2402,14 @@ class Period(_Period):
2397
2402
hour : int, default 0
2398
2403
minute : int, default 0
2399
2404
second : int, default 0
2405
+ dayfirst : bool, default None
2406
+ yearfirst : bool, default None
2400
2407
"""
2401
2408
2402
2409
def __new__ (cls , value = None , freq = None , ordinal = None ,
2403
2410
year = None , month = None , quarter = None , day = None ,
2404
- hour = None , minute = None , second = None ):
2411
+ hour = None , minute = None , second = None , dayfirst = None ,
2412
+ yearfirst = None ):
2405
2413
# freq points to a tuple (base, mult); base is one of the defined
2406
2414
# periods such as A, Q, etc. Every five minutes would be, e.g.,
2407
2415
# ('T', 5) but may be passed in as a string like '5T'
@@ -2457,7 +2465,8 @@ class Period(_Period):
2457
2465
if util.is_integer_object(value):
2458
2466
value = str (value)
2459
2467
value = value.upper()
2460
- dt, _, reso = parse_time_string(value, freq)
2468
+ dt, _, reso = parse_time_string(value, freq, dayfirst = dayfirst,
2469
+ yearfirst = yearfirst)
2461
2470
if dt is NaT:
2462
2471
ordinal = NPY_NAT
2463
2472
0 commit comments