From a6379b61b29b38ef55b7f3126c95614d404bd58d Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 21 Sep 2015 00:22:48 +0200 Subject: [PATCH] PERF: compare freq strings in extract_ordinals (GH11084) freq attribute changed to return Offset object instead of string, making this comparison much slower --- pandas/src/period.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/src/period.pyx b/pandas/src/period.pyx index 1dbf469a946b5..2a7c2135f8045 100644 --- a/pandas/src/period.pyx +++ b/pandas/src/period.pyx @@ -439,10 +439,12 @@ def extract_ordinals(ndarray[object] values, freq): ndarray[int64_t] ordinals = np.empty(n, dtype=np.int64) object p + freqstr = Period._maybe_convert_freq(freq).freqstr + for i in range(n): p = values[i] ordinals[i] = p.ordinal - if p.freq != freq: + if p.freqstr != freqstr: raise ValueError("%s is wrong freq" % p) return ordinals