Skip to content

Commit a6379b6

Browse files
PERF: compare freq strings in extract_ordinals (GH11084)
freq attribute changed to return Offset object instead of string, making this comparison much slower
1 parent 8ea8968 commit a6379b6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/src/period.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,12 @@ def extract_ordinals(ndarray[object] values, freq):
439439
ndarray[int64_t] ordinals = np.empty(n, dtype=np.int64)
440440
object p
441441

442+
freqstr = Period._maybe_convert_freq(freq).freqstr
443+
442444
for i in range(n):
443445
p = values[i]
444446
ordinals[i] = p.ordinal
445-
if p.freq != freq:
447+
if p.freqstr != freqstr:
446448
raise ValueError("%s is wrong freq" % p)
447449

448450
return ordinals

0 commit comments

Comments
 (0)