Generated by Cython 0.20 on Sat Jan 25 20:21:05 2014

Raw output: algos.c

     1: from numpy cimport *

      /* "pandas/algos.pyx":1
     * from numpy cimport *             # <<<<<<<<<<<<<<
     * cimport numpy as np
     * import numpy as np
     */
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     2: cimport numpy as np

     3: import numpy as np

      /* "pandas/algos.pyx":3
     * from numpy cimport *
     * cimport numpy as np
     * import numpy as np             # <<<<<<<<<<<<<<
     *
     * cimport cython
     */
      __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     4:

     5: cimport cython

     6:

     7: import_array()

      /* "pandas/algos.pyx":7
     * cimport cython
     *
     * import_array()             # <<<<<<<<<<<<<<
     *
     * cdef float64_t FP_ERR = 1e-13
     */
      import_array();

     8:

     9: cdef float64_t FP_ERR = 1e-13

      /* "pandas/algos.pyx":9
     * import_array()
     *
     * cdef float64_t FP_ERR = 1e-13             # <<<<<<<<<<<<<<
     *
     * cimport util
     */
      __pyx_v_6pandas_5algos_FP_ERR = 1e-13;

     10:

     11: cimport util

     12:

     13: from libc.stdlib cimport malloc, free

     14:

     15: from numpy cimport NPY_INT8 as NPY_int8

     16: from numpy cimport NPY_INT16 as NPY_int16

     17: from numpy cimport NPY_INT32 as NPY_int32

     18: from numpy cimport NPY_INT64 as NPY_int64

     19: from numpy cimport NPY_FLOAT16 as NPY_float16

     20: from numpy cimport NPY_FLOAT32 as NPY_float32

     21: from numpy cimport NPY_FLOAT64 as NPY_float64

     22:

     23: int8 = np.dtype(np.int8)

      /* "pandas/algos.pyx":23
     * from numpy cimport NPY_FLOAT64 as NPY_float64
     *
     * int8 = np.dtype(np.int8)             # <<<<<<<<<<<<<<
     * int16 = np.dtype(np.int16)
     * int32 = np.dtype(np.int32)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_int8, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     24: int16 = np.dtype(np.int16)

      /* "pandas/algos.pyx":24
     *
     * int8 = np.dtype(np.int8)
     * int16 = np.dtype(np.int16)             # <<<<<<<<<<<<<<
     * int32 = np.dtype(np.int32)
     * int64 = np.dtype(np.int64)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_int16, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     25: int32 = np.dtype(np.int32)

      /* "pandas/algos.pyx":25
     * int8 = np.dtype(np.int8)
     * int16 = np.dtype(np.int16)
     * int32 = np.dtype(np.int32)             # <<<<<<<<<<<<<<
     * int64 = np.dtype(np.int64)
     * float16 = np.dtype(np.float16)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_int32, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     26: int64 = np.dtype(np.int64)

      /* "pandas/algos.pyx":26
     * int16 = np.dtype(np.int16)
     * int32 = np.dtype(np.int32)
     * int64 = np.dtype(np.int64)             # <<<<<<<<<<<<<<
     * float16 = np.dtype(np.float16)
     * float32 = np.dtype(np.float32)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_int64, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     27: float16 = np.dtype(np.float16)

      /* "pandas/algos.pyx":27
     * int32 = np.dtype(np.int32)
     * int64 = np.dtype(np.int64)
     * float16 = np.dtype(np.float16)             # <<<<<<<<<<<<<<
     * float32 = np.dtype(np.float32)
     * float64 = np.dtype(np.float64)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_float16, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     28: float32 = np.dtype(np.float32)

      /* "pandas/algos.pyx":28
     * int64 = np.dtype(np.int64)
     * float16 = np.dtype(np.float16)
     * float32 = np.dtype(np.float32)             # <<<<<<<<<<<<<<
     * float64 = np.dtype(np.float64)
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_float32, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     29: float64 = np.dtype(np.float64)

      /* "pandas/algos.pyx":29
     * float16 = np.dtype(np.float16)
     * float32 = np.dtype(np.float32)
     * float64 = np.dtype(np.float64)             # <<<<<<<<<<<<<<
     *
     * cdef np.int8_t MINint8 = np.iinfo(np.int8).min
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_float64, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     30:

     31: cdef np.int8_t MINint8 = np.iinfo(np.int8).min

      /* "pandas/algos.pyx":31
     * float64 = np.dtype(np.float64)
     *
     * cdef np.int8_t MINint8 = np.iinfo(np.int8).min             # <<<<<<<<<<<<<<
     * cdef np.int16_t MINint16 = np.iinfo(np.int16).min
     * cdef np.int32_t MINint32 = np.iinfo(np.int32).min
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_min); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyInt_As_npy_int8(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MINint8 = __pyx_t_4;

     32: cdef np.int16_t MINint16 = np.iinfo(np.int16).min

      /* "pandas/algos.pyx":32
     *
     * cdef np.int8_t MINint8 = np.iinfo(np.int8).min
     * cdef np.int16_t MINint16 = np.iinfo(np.int16).min             # <<<<<<<<<<<<<<
     * cdef np.int32_t MINint32 = np.iinfo(np.int32).min
     * cdef np.int64_t MINint64 = np.iinfo(np.int64).min
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_min); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyInt_As_npy_int16(__pyx_t_2); if (unlikely((__pyx_t_5 == (npy_int16)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MINint16 = __pyx_t_5;

     33: cdef np.int32_t MINint32 = np.iinfo(np.int32).min

      /* "pandas/algos.pyx":33
     * cdef np.int8_t MINint8 = np.iinfo(np.int8).min
     * cdef np.int16_t MINint16 = np.iinfo(np.int16).min
     * cdef np.int32_t MINint32 = np.iinfo(np.int32).min             # <<<<<<<<<<<<<<
     * cdef np.int64_t MINint64 = np.iinfo(np.int64).min
     * cdef np.float16_t MINfloat16 = np.NINF
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_min); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_npy_int32(__pyx_t_2); if (unlikely((__pyx_t_6 == (npy_int32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MINint32 = __pyx_t_6;

     34: cdef np.int64_t MINint64 = np.iinfo(np.int64).min

      /* "pandas/algos.pyx":34
     * cdef np.int16_t MINint16 = np.iinfo(np.int16).min
     * cdef np.int32_t MINint32 = np.iinfo(np.int32).min
     * cdef np.int64_t MINint64 = np.iinfo(np.int64).min             # <<<<<<<<<<<<<<
     * cdef np.float16_t MINfloat16 = np.NINF
     * cdef np.float32_t MINfloat32 = np.NINF
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_min); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_npy_int64(__pyx_t_2); if (unlikely((__pyx_t_7 == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MINint64 = __pyx_t_7;

     35: cdef np.float16_t MINfloat16 = np.NINF

      /* "pandas/algos.pyx":35
     * cdef np.int32_t MINint32 = np.iinfo(np.int32).min
     * cdef np.int64_t MINint64 = np.iinfo(np.int64).min
     * cdef np.float16_t MINfloat16 = np.NINF             # <<<<<<<<<<<<<<
     * cdef np.float32_t MINfloat32 = np.NINF
     * cdef np.float64_t MINfloat64 = np.NINF
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NINF); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_8 == (npy_float16)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MINfloat16 = __pyx_t_8;

     36: cdef np.float32_t MINfloat32 = np.NINF

      /* "pandas/algos.pyx":36
     * cdef np.int64_t MINint64 = np.iinfo(np.int64).min
     * cdef np.float16_t MINfloat16 = np.NINF
     * cdef np.float32_t MINfloat32 = np.NINF             # <<<<<<<<<<<<<<
     * cdef np.float64_t MINfloat64 = np.NINF
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NINF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MINfloat32 = __pyx_t_9;

     37: cdef np.float64_t MINfloat64 = np.NINF

      /* "pandas/algos.pyx":37
     * cdef np.float16_t MINfloat16 = np.NINF
     * cdef np.float32_t MINfloat32 = np.NINF
     * cdef np.float64_t MINfloat64 = np.NINF             # <<<<<<<<<<<<<<
     *
     * cdef np.int8_t MAXint8 = np.iinfo(np.int8).max
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NINF); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MINfloat64 = __pyx_t_10;

     38:

     39: cdef np.int8_t MAXint8 = np.iinfo(np.int8).max

      /* "pandas/algos.pyx":39
     * cdef np.float64_t MINfloat64 = np.NINF
     *
     * cdef np.int8_t MAXint8 = np.iinfo(np.int8).max             # <<<<<<<<<<<<<<
     * cdef np.int16_t MAXint16 = np.iinfo(np.int16).max
     * cdef np.int32_t MAXint32 = np.iinfo(np.int32).max
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyInt_As_npy_int8(__pyx_t_1); if (unlikely((__pyx_t_4 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MAXint8 = __pyx_t_4;

     40: cdef np.int16_t MAXint16 = np.iinfo(np.int16).max

      /* "pandas/algos.pyx":40
     *
     * cdef np.int8_t MAXint8 = np.iinfo(np.int8).max
     * cdef np.int16_t MAXint16 = np.iinfo(np.int16).max             # <<<<<<<<<<<<<<
     * cdef np.int32_t MAXint32 = np.iinfo(np.int32).max
     * cdef np.int64_t MAXint64 = np.iinfo(np.int64).max
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = __Pyx_PyInt_As_npy_int16(__pyx_t_1); if (unlikely((__pyx_t_5 == (npy_int16)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MAXint16 = __pyx_t_5;

     41: cdef np.int32_t MAXint32 = np.iinfo(np.int32).max

      /* "pandas/algos.pyx":41
     * cdef np.int8_t MAXint8 = np.iinfo(np.int8).max
     * cdef np.int16_t MAXint16 = np.iinfo(np.int16).max
     * cdef np.int32_t MAXint32 = np.iinfo(np.int32).max             # <<<<<<<<<<<<<<
     * cdef np.int64_t MAXint64 = np.iinfo(np.int64).max
     * cdef np.float16_t MAXfloat16 = np.inf
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_6 == (npy_int32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MAXint32 = __pyx_t_6;

     42: cdef np.int64_t MAXint64 = np.iinfo(np.int64).max

      /* "pandas/algos.pyx":42
     * cdef np.int16_t MAXint16 = np.iinfo(np.int16).max
     * cdef np.int32_t MAXint32 = np.iinfo(np.int32).max
     * cdef np.int64_t MAXint64 = np.iinfo(np.int64).max             # <<<<<<<<<<<<<<
     * cdef np.float16_t MAXfloat16 = np.inf
     * cdef np.float32_t MAXfloat32 = np.inf
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_npy_int64(__pyx_t_1); if (unlikely((__pyx_t_7 == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MAXint64 = __pyx_t_7;

     43: cdef np.float16_t MAXfloat16 = np.inf

      /* "pandas/algos.pyx":43
     * cdef np.int32_t MAXint32 = np.iinfo(np.int32).max
     * cdef np.int64_t MAXint64 = np.iinfo(np.int64).max
     * cdef np.float16_t MAXfloat16 = np.inf             # <<<<<<<<<<<<<<
     * cdef np.float32_t MAXfloat32 = np.inf
     * cdef np.float64_t MAXfloat64 = np.inf
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_8 == (npy_float16)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MAXfloat16 = __pyx_t_8;

     44: cdef np.float32_t MAXfloat32 = np.inf

      /* "pandas/algos.pyx":44
     * cdef np.int64_t MAXint64 = np.iinfo(np.int64).max
     * cdef np.float16_t MAXfloat16 = np.inf
     * cdef np.float32_t MAXfloat32 = np.inf             # <<<<<<<<<<<<<<
     * cdef np.float64_t MAXfloat64 = np.inf
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_MAXfloat32 = __pyx_t_9;

     45: cdef np.float64_t MAXfloat64 = np.inf

      /* "pandas/algos.pyx":45
     * cdef np.float16_t MAXfloat16 = np.inf
     * cdef np.float32_t MAXfloat32 = np.inf
     * cdef np.float64_t MAXfloat64 = np.inf             # <<<<<<<<<<<<<<
     *
     * cdef double NaN = <double> np.NaN
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_6pandas_5algos_MAXfloat64 = __pyx_t_10;

     46:

     47: cdef double NaN = <double> np.NaN

      /* "pandas/algos.pyx":47
     * cdef np.float64_t MAXfloat64 = np.inf
     *
     * cdef double NaN = <double> np.NaN             # <<<<<<<<<<<<<<
     * cdef double nan = NaN
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NaN); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_6pandas_5algos_NaN = ((double)__pyx_t_11);

     48: cdef double nan = NaN

      /* "pandas/algos.pyx":48
     *
     * cdef double NaN = <double> np.NaN
     * cdef double nan = NaN             # <<<<<<<<<<<<<<
     *
     *
     */
      __pyx_v_6pandas_5algos_nan = __pyx_v_6pandas_5algos_NaN;

     49:

     50:

     51: cdef inline int int_max(int a, int b): return a if a >= b else b

    /* "pandas/algos.pyx":51
     *
     *
     * cdef inline int int_max(int a, int b): return a if a >= b else b             # <<<<<<<<<<<<<<
     * cdef inline int int_min(int a, int b): return a if a <= b else b
     *
     */

    static CYTHON_INLINE int __pyx_f_6pandas_5algos_int_max(int __pyx_v_a, int __pyx_v_b) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("int_max", 0);
      if (((__pyx_v_a >= __pyx_v_b) != 0)) {
        __pyx_t_1 = __pyx_v_a;
      } else {
        __pyx_t_1 = __pyx_v_b;
      }
      __pyx_r = __pyx_t_1;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     52: cdef inline int int_min(int a, int b): return a if a <= b else b

    /* "pandas/algos.pyx":52
     *
     * cdef inline int int_max(int a, int b): return a if a >= b else b
     * cdef inline int int_min(int a, int b): return a if a <= b else b             # <<<<<<<<<<<<<<
     *
     *
     */

    static CYTHON_INLINE int __pyx_f_6pandas_5algos_int_min(int __pyx_v_a, int __pyx_v_b) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("int_min", 0);
      if (((__pyx_v_a <= __pyx_v_b) != 0)) {
        __pyx_t_1 = __pyx_v_a;
      } else {
        __pyx_t_1 = __pyx_v_b;
      }
      __pyx_r = __pyx_t_1;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     53:

     54:

     55: cdef extern from "src/headers/math.h":

     56:     double sqrt(double x)

     57:     double fabs(double)

     58:     int signbit(double)

     59:

     60: from pandas import lib

      /* "pandas/algos.pyx":60
     *     int signbit(double)
     *
     * from pandas import lib             # <<<<<<<<<<<<<<
     *
     * include "skiplist.pyx"
     */
      __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_n_s_lib);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_lib);
      __Pyx_GIVEREF(__pyx_n_s_lib);
      __pyx_t_2 = __Pyx_Import(__pyx_n_s_pandas, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_lib); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_lib, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     61:

     62: include "skiplist.pyx"

     63:

     64:

     65: cdef:

     66:     int TIEBREAK_AVERAGE = 0

      /* "pandas/algos.pyx":66
     *
     * cdef:
     *     int TIEBREAK_AVERAGE = 0             # <<<<<<<<<<<<<<
     *     int TIEBREAK_MIN = 1
     *     int TIEBREAK_MAX = 2
     */
      __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE = 0;

     67:     int TIEBREAK_MIN = 1

      /* "pandas/algos.pyx":67
     * cdef:
     *     int TIEBREAK_AVERAGE = 0
     *     int TIEBREAK_MIN = 1             # <<<<<<<<<<<<<<
     *     int TIEBREAK_MAX = 2
     *     int TIEBREAK_FIRST = 3
     */
      __pyx_v_6pandas_5algos_TIEBREAK_MIN = 1;

     68:     int TIEBREAK_MAX = 2

      /* "pandas/algos.pyx":68
     *     int TIEBREAK_AVERAGE = 0
     *     int TIEBREAK_MIN = 1
     *     int TIEBREAK_MAX = 2             # <<<<<<<<<<<<<<
     *     int TIEBREAK_FIRST = 3
     *     int TIEBREAK_FIRST_DESCENDING = 4
     */
      __pyx_v_6pandas_5algos_TIEBREAK_MAX = 2;

     69:     int TIEBREAK_FIRST = 3

      /* "pandas/algos.pyx":69
     *     int TIEBREAK_MIN = 1
     *     int TIEBREAK_MAX = 2
     *     int TIEBREAK_FIRST = 3             # <<<<<<<<<<<<<<
     *     int TIEBREAK_FIRST_DESCENDING = 4
     *
     */
      __pyx_v_6pandas_5algos_TIEBREAK_FIRST = 3;

     70:     int TIEBREAK_FIRST_DESCENDING = 4

      /* "pandas/algos.pyx":70
     *     int TIEBREAK_MAX = 2
     *     int TIEBREAK_FIRST = 3
     *     int TIEBREAK_FIRST_DESCENDING = 4             # <<<<<<<<<<<<<<
     *
     * tiebreakers = {
     */
      __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING = 4;

     71:

     72: tiebreakers = {

      /* "pandas/algos.pyx":72
     *     int TIEBREAK_FIRST_DESCENDING = 4
     *
     * tiebreakers = {             # <<<<<<<<<<<<<<
     *     'average' : TIEBREAK_AVERAGE,
     *     'min' : TIEBREAK_MIN,
     */
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);

     73:     'average' : TIEBREAK_AVERAGE,

      /* "pandas/algos.pyx":73
     *
     * tiebreakers = {
     *     'average' : TIEBREAK_AVERAGE,             # <<<<<<<<<<<<<<
     *     'min' : TIEBREAK_MIN,
     *     'max' : TIEBREAK_MAX,
     */
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_6pandas_5algos_TIEBREAK_AVERAGE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_average, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

     74:     'min' : TIEBREAK_MIN,

      /* "pandas/algos.pyx":74
     * tiebreakers = {
     *     'average' : TIEBREAK_AVERAGE,
     *     'min' : TIEBREAK_MIN,             # <<<<<<<<<<<<<<
     *     'max' : TIEBREAK_MAX,
     *     'first' : TIEBREAK_FIRST
     */
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_6pandas_5algos_TIEBREAK_MIN); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_min, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

     75:     'max' : TIEBREAK_MAX,

      /* "pandas/algos.pyx":75
     *     'average' : TIEBREAK_AVERAGE,
     *     'min' : TIEBREAK_MIN,
     *     'max' : TIEBREAK_MAX,             # <<<<<<<<<<<<<<
     *     'first' : TIEBREAK_FIRST
     * }
     */
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_6pandas_5algos_TIEBREAK_MAX); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_max, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

     76:     'first' : TIEBREAK_FIRST

     77: }

      /* "pandas/algos.pyx":77
     *     'max' : TIEBREAK_MAX,
     *     'first' : TIEBREAK_FIRST
     * }             # <<<<<<<<<<<<<<
     *
     *
     */
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_6pandas_5algos_TIEBREAK_FIRST); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_first, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_tiebreakers, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     78:

     79:

     80: # ctypedef fused pvalue_t:

     81: #     float64_t

     82: #     int64_t

     83: #     object

     84:

     85: # from cython cimport floating, integral

     86:

     87: cdef _take_2d_float64(ndarray[float64_t, ndim=2] values,

    /* "pandas/algos.pyx":87
     * # from cython cimport floating, integral
     *
     * cdef _take_2d_float64(ndarray[float64_t, ndim=2] values,             # <<<<<<<<<<<<<<
     *                       object idx):
     *     cdef:
     */

    static PyObject *__pyx_f_6pandas_5algos__take_2d_float64(PyArrayObject *__pyx_v_values, PyObject *__pyx_v_idx) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      PyArrayObject *__pyx_v_indexer = 0;
      PyArrayObject *__pyx_v_result = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_indexer;
      __Pyx_Buffer __pyx_pybuffer_indexer;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_take_2d_float64", 0);
      __pyx_pybuffer_indexer.pybuffer.buf = NULL;
      __pyx_pybuffer_indexer.refcount = 0;
      __pyx_pybuffernd_indexer.data = NULL;
      __pyx_pybuffernd_indexer.rcbuffer = &__pyx_pybuffer_indexer;
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];

      /* "pandas/algos.pyx":87
     * # from cython cimport floating, integral
     *
     * cdef _take_2d_float64(ndarray[float64_t, ndim=2] values,             # <<<<<<<<<<<<<<
     *                       object idx):
     *     cdef:
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos._take_2d_float64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
      __Pyx_XDECREF((PyObject *)__pyx_v_result);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     88:                       object idx):

     89:     cdef:

     90:         Py_ssize_t i, j, N, K

     91:         ndarray[Py_ssize_t, ndim=2, cast=True] indexer = idx

      /* "pandas/algos.pyx":91
     *     cdef:
     *         Py_ssize_t i, j, N, K
     *         ndarray[Py_ssize_t, ndim=2, cast=True] indexer = idx             # <<<<<<<<<<<<<<
     *         ndarray[float64_t, ndim=2] result
     *         object val
     */
      if (!(likely(((__pyx_v_idx) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_idx, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __pyx_v_idx;
      __Pyx_INCREF(__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_Py_ssize_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack) == -1)) {
          __pyx_v_indexer = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_indexer.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_indexer.diminfo[0].strides = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indexer.diminfo[0].shape = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indexer.diminfo[1].strides = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indexer.diminfo[1].shape = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_v_indexer = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     92:         ndarray[float64_t, ndim=2] result

     93:         object val

     94:

     95:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":95
     *         object val
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *     result = np.empty_like(values)
     *     for i in range(N):
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_6;
      __pyx_v_K = __pyx_t_7;

     96:     result = np.empty_like(values)

      /* "pandas/algos.pyx":96
     *
     *     N, K = (<object> values).shape
     *     result = np.empty_like(values)             # <<<<<<<<<<<<<<
     *     for i in range(N):
     *         for j in range(K):
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_result = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     97:     for i in range(N):

      /* "pandas/algos.pyx":97
     *     N, K = (<object> values).shape
     *     result = np.empty_like(values)
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]
     */
      __pyx_t_7 = __pyx_v_N;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6+=1) {
        __pyx_v_i = __pyx_t_6;

     98:         for j in range(K):

        /* "pandas/algos.pyx":98
     *     result = np.empty_like(values)
     *     for i in range(N):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             result[i, j] = values[i, indexer[i, j]]
     *     return result
     */
        __pyx_t_13 = __pyx_v_K;
        for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
          __pyx_v_j = __pyx_t_14;

     99:             result[i, j] = values[i, indexer[i, j]]

          /* "pandas/algos.pyx":99
     *     for i in range(N):
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]             # <<<<<<<<<<<<<<
     *     return result
     *
     */
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_16 = __pyx_v_j;
          __pyx_t_9 = -1;
          if (__pyx_t_15 < 0) {
            __pyx_t_15 += __pyx_pybuffernd_indexer.diminfo[0].shape;
            if (unlikely(__pyx_t_15 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_indexer.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_16 < 0) {
            __pyx_t_16 += __pyx_pybuffernd_indexer.diminfo[1].shape;
            if (unlikely(__pyx_t_16 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indexer.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_18 = (*__Pyx_BufPtrStrided2d(Py_ssize_t *, __pyx_pybuffernd_indexer.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_indexer.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_indexer.diminfo[1].strides));
          __pyx_t_9 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_values.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_values.diminfo[1].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_20 = __pyx_v_j;
          __pyx_t_9 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_result.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_result.diminfo[1].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_result.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_result.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_values.diminfo[1].strides));
        }
      }

     100:     return result

      /* "pandas/algos.pyx":100
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]
     *     return result             # <<<<<<<<<<<<<<
     *
     * cdef _take_2d_int64(ndarray[int64_t, ndim=2] values,
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      __pyx_r = ((PyObject *)__pyx_v_result);
      goto __pyx_L0;

     101:

     102: cdef _take_2d_int64(ndarray[int64_t, ndim=2] values,

    /* "pandas/algos.pyx":102
     *     return result
     *
     * cdef _take_2d_int64(ndarray[int64_t, ndim=2] values,             # <<<<<<<<<<<<<<
     *                       object idx):
     *     cdef:
     */

    static PyObject *__pyx_f_6pandas_5algos__take_2d_int64(PyArrayObject *__pyx_v_values, PyObject *__pyx_v_idx) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      PyArrayObject *__pyx_v_indexer = 0;
      PyArrayObject *__pyx_v_result = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_indexer;
      __Pyx_Buffer __pyx_pybuffer_indexer;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_take_2d_int64", 0);
      __pyx_pybuffer_indexer.pybuffer.buf = NULL;
      __pyx_pybuffer_indexer.refcount = 0;
      __pyx_pybuffernd_indexer.data = NULL;
      __pyx_pybuffernd_indexer.rcbuffer = &__pyx_pybuffer_indexer;
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];

      /* "pandas/algos.pyx":102
     *     return result
     *
     * cdef _take_2d_int64(ndarray[int64_t, ndim=2] values,             # <<<<<<<<<<<<<<
     *                       object idx):
     *     cdef:
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos._take_2d_int64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
      __Pyx_XDECREF((PyObject *)__pyx_v_result);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     103:                       object idx):

     104:     cdef:

     105:         Py_ssize_t i, j, N, K

     106:         ndarray[Py_ssize_t, ndim=2, cast=True] indexer = idx

      /* "pandas/algos.pyx":106
     *     cdef:
     *         Py_ssize_t i, j, N, K
     *         ndarray[Py_ssize_t, ndim=2, cast=True] indexer = idx             # <<<<<<<<<<<<<<
     *         ndarray[int64_t, ndim=2] result
     *         object val
     */
      if (!(likely(((__pyx_v_idx) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_idx, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __pyx_v_idx;
      __Pyx_INCREF(__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_Py_ssize_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack) == -1)) {
          __pyx_v_indexer = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_indexer.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_indexer.diminfo[0].strides = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indexer.diminfo[0].shape = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indexer.diminfo[1].strides = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indexer.diminfo[1].shape = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_v_indexer = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     107:         ndarray[int64_t, ndim=2] result

     108:         object val

     109:

     110:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":110
     *         object val
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *     result = np.empty_like(values)
     *     for i in range(N):
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_6;
      __pyx_v_K = __pyx_t_7;

     111:     result = np.empty_like(values)

      /* "pandas/algos.pyx":111
     *
     *     N, K = (<object> values).shape
     *     result = np.empty_like(values)             # <<<<<<<<<<<<<<
     *     for i in range(N):
     *         for j in range(K):
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_result = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     112:     for i in range(N):

      /* "pandas/algos.pyx":112
     *     N, K = (<object> values).shape
     *     result = np.empty_like(values)
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]
     */
      __pyx_t_7 = __pyx_v_N;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6+=1) {
        __pyx_v_i = __pyx_t_6;

     113:         for j in range(K):

        /* "pandas/algos.pyx":113
     *     result = np.empty_like(values)
     *     for i in range(N):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             result[i, j] = values[i, indexer[i, j]]
     *     return result
     */
        __pyx_t_13 = __pyx_v_K;
        for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
          __pyx_v_j = __pyx_t_14;

     114:             result[i, j] = values[i, indexer[i, j]]

          /* "pandas/algos.pyx":114
     *     for i in range(N):
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]             # <<<<<<<<<<<<<<
     *     return result
     *
     */
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_16 = __pyx_v_j;
          __pyx_t_9 = -1;
          if (__pyx_t_15 < 0) {
            __pyx_t_15 += __pyx_pybuffernd_indexer.diminfo[0].shape;
            if (unlikely(__pyx_t_15 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_indexer.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_16 < 0) {
            __pyx_t_16 += __pyx_pybuffernd_indexer.diminfo[1].shape;
            if (unlikely(__pyx_t_16 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indexer.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_18 = (*__Pyx_BufPtrStrided2d(Py_ssize_t *, __pyx_pybuffernd_indexer.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_indexer.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_indexer.diminfo[1].strides));
          __pyx_t_9 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_values.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_values.diminfo[1].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_20 = __pyx_v_j;
          __pyx_t_9 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_result.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_result.diminfo[1].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_result.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_result.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_values.diminfo[1].strides));
        }
      }

     115:     return result

      /* "pandas/algos.pyx":115
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]
     *     return result             # <<<<<<<<<<<<<<
     *
     * cdef _take_2d_object(ndarray[object, ndim=2] values,
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      __pyx_r = ((PyObject *)__pyx_v_result);
      goto __pyx_L0;

     116:

     117: cdef _take_2d_object(ndarray[object, ndim=2] values,

    /* "pandas/algos.pyx":117
     *     return result
     *
     * cdef _take_2d_object(ndarray[object, ndim=2] values,             # <<<<<<<<<<<<<<
     *                      object idx):
     *     cdef:
     */

    static PyObject *__pyx_f_6pandas_5algos__take_2d_object(PyArrayObject *__pyx_v_values, PyObject *__pyx_v_idx) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      PyArrayObject *__pyx_v_indexer = 0;
      PyArrayObject *__pyx_v_result = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_indexer;
      __Pyx_Buffer __pyx_pybuffer_indexer;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_take_2d_object", 0);
      __pyx_pybuffer_indexer.pybuffer.buf = NULL;
      __pyx_pybuffer_indexer.refcount = 0;
      __pyx_pybuffernd_indexer.data = NULL;
      __pyx_pybuffernd_indexer.rcbuffer = &__pyx_pybuffer_indexer;
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];

      /* "pandas/algos.pyx":117
     *     return result
     *
     * cdef _take_2d_object(ndarray[object, ndim=2] values,             # <<<<<<<<<<<<<<
     *                      object idx):
     *     cdef:
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos._take_2d_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
      __Pyx_XDECREF((PyObject *)__pyx_v_result);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     118:                      object idx):

     119:     cdef:

     120:         Py_ssize_t i, j, N, K

     121:         ndarray[Py_ssize_t, ndim=2, cast=True] indexer = idx

      /* "pandas/algos.pyx":121
     *     cdef:
     *         Py_ssize_t i, j, N, K
     *         ndarray[Py_ssize_t, ndim=2, cast=True] indexer = idx             # <<<<<<<<<<<<<<
     *         ndarray[object, ndim=2] result
     *         object val
     */
      if (!(likely(((__pyx_v_idx) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_idx, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __pyx_v_idx;
      __Pyx_INCREF(__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indexer.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_Py_ssize_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack) == -1)) {
          __pyx_v_indexer = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_indexer.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_indexer.diminfo[0].strides = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indexer.diminfo[0].shape = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indexer.diminfo[1].strides = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indexer.diminfo[1].shape = __pyx_pybuffernd_indexer.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_v_indexer = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     122:         ndarray[object, ndim=2] result

     123:         object val

     124:

     125:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":125
     *         object val
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *     result = values.copy()
     *     for i in range(N):
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_6;
      __pyx_v_K = __pyx_t_7;

     126:     result = values.copy()

      /* "pandas/algos.pyx":126
     *
     *     N, K = (<object> values).shape
     *     result = values.copy()             # <<<<<<<<<<<<<<
     *     for i in range(N):
     *         for j in range(K):
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_result = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;

     127:     for i in range(N):

      /* "pandas/algos.pyx":127
     *     N, K = (<object> values).shape
     *     result = values.copy()
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]
     */
      __pyx_t_7 = __pyx_v_N;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6+=1) {
        __pyx_v_i = __pyx_t_6;

     128:         for j in range(K):

        /* "pandas/algos.pyx":128
     *     result = values.copy()
     *     for i in range(N):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             result[i, j] = values[i, indexer[i, j]]
     *     return result
     */
        __pyx_t_13 = __pyx_v_K;
        for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
          __pyx_v_j = __pyx_t_14;

     129:             result[i, j] = values[i, indexer[i, j]]

          /* "pandas/algos.pyx":129
     *     for i in range(N):
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]             # <<<<<<<<<<<<<<
     *     return result
     *
     */
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_16 = __pyx_v_j;
          __pyx_t_9 = -1;
          if (__pyx_t_15 < 0) {
            __pyx_t_15 += __pyx_pybuffernd_indexer.diminfo[0].shape;
            if (unlikely(__pyx_t_15 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_indexer.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_16 < 0) {
            __pyx_t_16 += __pyx_pybuffernd_indexer.diminfo[1].shape;
            if (unlikely(__pyx_t_16 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indexer.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_18 = (*__Pyx_BufPtrStrided2d(Py_ssize_t *, __pyx_pybuffernd_indexer.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_indexer.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_indexer.diminfo[1].strides));
          __pyx_t_9 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_values.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_values.diminfo[1].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_3 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_values.diminfo[1].strides);
          __Pyx_INCREF((PyObject*)__pyx_t_3);
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_20 = __pyx_v_j;
          __pyx_t_9 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_result.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_result.diminfo[1].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_result.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_21 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_result.diminfo[1].strides);
          __Pyx_GOTREF(*__pyx_t_21);
          __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(*__pyx_t_21);
          *__pyx_t_21 = __pyx_t_3;
          __Pyx_GIVEREF(*__pyx_t_21);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
      }

     130:     return result

      /* "pandas/algos.pyx":130
     *         for j in range(K):
     *             result[i, j] = values[i, indexer[i, j]]
     *     return result             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      __pyx_r = ((PyObject *)__pyx_v_result);
      goto __pyx_L0;

     131:

     132:

     133: def rank_1d_float64(object in_arr, ties_method='average', ascending=True,

    /* "pandas/algos.pyx":133
     *
     *
     * def rank_1d_float64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                     na_option='keep'):
     *     """
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_1rank_1d_float64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_rank_1d_float64[] = "\n    Fast NaN-friendly version of scipy.stats.rankdata\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_1rank_1d_float64 = {__Pyx_NAMESTR("rank_1d_float64"), (PyCFunction)__pyx_pw_6pandas_5algos_1rank_1d_float64, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_rank_1d_float64)};
    static PyObject *__pyx_pw_6pandas_5algos_1rank_1d_float64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_in_arr = 0;
      PyObject *__pyx_v_ties_method = 0;
      PyObject *__pyx_v_ascending = 0;
      PyObject *__pyx_v_na_option = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_1d_float64 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_arr,&__pyx_n_s_ties_method,&__pyx_n_s_ascending,&__pyx_n_s_na_option,0};
        PyObject* values[4] = {0,0,0,0};
        values[1] = ((PyObject *)__pyx_n_s_average);
        values[2] = ((PyObject *)Py_True);
        values[3] = ((PyObject *)__pyx_n_s_keep);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arr)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ties_method);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ascending);
              if (value) { values[2] = value; kw_args--; }
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_na_option);
              if (value) { values[3] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rank_1d_float64") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_in_arr = values[0];
        __pyx_v_ties_method = values[1];
        __pyx_v_ascending = values[2];
        __pyx_v_na_option = values[3];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("rank_1d_float64", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.rank_1d_float64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_rank_1d_float64(__pyx_self, __pyx_v_in_arr, __pyx_v_ties_method, __pyx_v_ascending, __pyx_v_na_option);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_rank_1d_float64(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_arr, PyObject *__pyx_v_ties_method, PyObject *__pyx_v_ascending, PyObject *__pyx_v_na_option) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_dups;
      PyArrayObject *__pyx_v_sorted_data = 0;
      PyArrayObject *__pyx_v_ranks = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_argsorted = 0;
      __pyx_t_5numpy_float64_t __pyx_v_val;
      __pyx_t_5numpy_float64_t __pyx_v_nan_value;
      __pyx_t_5numpy_float64_t __pyx_v_sum_ranks;
      int __pyx_v_tiebreak;
      int __pyx_v_keep_na;
      PyObject *__pyx_v_mask = NULL;
      PyObject *__pyx_v__as = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_argsorted;
      __Pyx_Buffer __pyx_pybuffer_argsorted;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_ranks;
      __Pyx_Buffer __pyx_pybuffer_ranks;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_sorted_data;
      __Pyx_Buffer __pyx_pybuffer_sorted_data;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_1d_float64", 0);
      __pyx_pybuffer_sorted_data.pybuffer.buf = NULL;
      __pyx_pybuffer_sorted_data.refcount = 0;
      __pyx_pybuffernd_sorted_data.data = NULL;
      __pyx_pybuffernd_sorted_data.rcbuffer = &__pyx_pybuffer_sorted_data;
      __pyx_pybuffer_ranks.pybuffer.buf = NULL;
      __pyx_pybuffer_ranks.refcount = 0;
      __pyx_pybuffernd_ranks.data = NULL;
      __pyx_pybuffernd_ranks.rcbuffer = &__pyx_pybuffer_ranks;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_argsorted.pybuffer.buf = NULL;
      __pyx_pybuffer_argsorted.refcount = 0;
      __pyx_pybuffernd_argsorted.data = NULL;
      __pyx_pybuffernd_argsorted.rcbuffer = &__pyx_pybuffer_argsorted;

      /* "pandas/algos.pyx":133
     *
     *
     * def rank_1d_float64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                     na_option='keep'):
     *     """
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_12);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.rank_1d_float64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_sorted_data);
      __Pyx_XDECREF((PyObject *)__pyx_v_ranks);
      __Pyx_XDECREF((PyObject *)__pyx_v_values);
      __Pyx_XDECREF((PyObject *)__pyx_v_argsorted);
      __Pyx_XDECREF(__pyx_v_mask);
      __Pyx_XDECREF(__pyx_v__as);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":133
     *
     *
     * def rank_1d_float64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                     na_option='keep'):
     *     """
     */
      __pyx_tuple__216 = PyTuple_Pack(19, __pyx_n_s_in_arr, __pyx_n_s_ties_method, __pyx_n_s_ascending, __pyx_n_s_na_option, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_n, __pyx_n_s_dups, __pyx_n_s_sorted_data, __pyx_n_s_ranks, __pyx_n_s_values, __pyx_n_s_argsorted, __pyx_n_s_val, __pyx_n_s_nan_value, __pyx_n_s_sum_ranks, __pyx_n_s_tiebreak, __pyx_n_s_keep_na, __pyx_n_s_mask, __pyx_n_s_as); if (unlikely(!__pyx_tuple__216)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__216);
      __Pyx_GIVEREF(__pyx_tuple__216);

      /* "pandas/algos.pyx":133
     *
     *
     * def rank_1d_float64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                     na_option='keep'):
     *     """
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_1rank_1d_float64, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rank_1d_float64, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__217 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__216, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_rank_1d_float64, 133, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__217)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     134:                     na_option='keep'):

     135:     """

     136:     Fast NaN-friendly version of scipy.stats.rankdata

     137:     """

     138:

     139:     cdef:

     140:         Py_ssize_t i, j, n, dups = 0

      /* "pandas/algos.pyx":140
     *
     *     cdef:
     *         Py_ssize_t i, j, n, dups = 0             # <<<<<<<<<<<<<<
     *         ndarray[float64_t] sorted_data, ranks, values
     *         ndarray[int64_t] argsorted
     */
      __pyx_v_dups = 0;

     141:         ndarray[float64_t] sorted_data, ranks, values

     142:         ndarray[int64_t] argsorted

     143:         float64_t val, nan_value

     144:         float64_t sum_ranks = 0

      /* "pandas/algos.pyx":144
     *         ndarray[int64_t] argsorted
     *         float64_t val, nan_value
     *         float64_t sum_ranks = 0             # <<<<<<<<<<<<<<
     *         int tiebreak = 0
     *         bint keep_na = 0
     */
      __pyx_v_sum_ranks = 0.0;

     145:         int tiebreak = 0

      /* "pandas/algos.pyx":145
     *         float64_t val, nan_value
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0             # <<<<<<<<<<<<<<
     *         bint keep_na = 0
     *     tiebreak = tiebreakers[ties_method]
     */
      __pyx_v_tiebreak = 0;

     146:         bint keep_na = 0

      /* "pandas/algos.pyx":146
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0
     *         bint keep_na = 0             # <<<<<<<<<<<<<<
     *     tiebreak = tiebreakers[ties_method]
     *
     */
      __pyx_v_keep_na = 0;

     147:     tiebreak = tiebreakers[ties_method]

      /* "pandas/algos.pyx":147
     *         int tiebreak = 0
     *         bint keep_na = 0
     *     tiebreak = tiebreakers[ties_method]             # <<<<<<<<<<<<<<
     *
     *     values = np.asarray(in_arr).copy()
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tiebreakers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_ties_method); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tiebreak = __pyx_t_3;

     148:

     149:     values = np.asarray(in_arr).copy()

      /* "pandas/algos.pyx":149
     *     tiebreak = tiebreakers[ties_method]
     *
     *     values = np.asarray(in_arr).copy()             # <<<<<<<<<<<<<<
     *
     *     keep_na = na_option == 'keep'
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_in_arr);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
      __Pyx_GIVEREF(__pyx_v_in_arr);
      __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __pyx_v_values = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

     150:

     151:     keep_na = na_option == 'keep'

      /* "pandas/algos.pyx":151
     *     values = np.asarray(in_arr).copy()
     *
     *     keep_na = na_option == 'keep'             # <<<<<<<<<<<<<<
     *
     *     if ascending ^ (na_option == 'top'):
     */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_keep, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_keep_na = __pyx_t_9;

     152:

     153:     if ascending ^ (na_option == 'top'):

      /* "pandas/algos.pyx":153
     *     keep_na = na_option == 'keep'
     *
     *     if ascending ^ (na_option == 'top'):             # <<<<<<<<<<<<<<
     *         nan_value = np.inf
     *     else:
     */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_top, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyNumber_Xor(__pyx_v_ascending, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_9) {

     154:         nan_value = np.inf

        /* "pandas/algos.pyx":154
     *
     *     if ascending ^ (na_option == 'top'):
     *         nan_value = np.inf             # <<<<<<<<<<<<<<
     *     else:
     *         nan_value = -np.inf
     */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_inf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_nan_value = __pyx_t_10;
        goto __pyx_L3;
      }
      /*else*/ {

     155:     else:

     156:         nan_value = -np.inf

        /* "pandas/algos.pyx":156
     *         nan_value = np.inf
     *     else:
     *         nan_value = -np.inf             # <<<<<<<<<<<<<<
     *     mask = np.isnan(values)
     *     np.putmask(values, mask, nan_value)
     */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_nan_value = __pyx_t_10;
      }
      __pyx_L3:;

     157:     mask = np.isnan(values)

      /* "pandas/algos.pyx":157
     *     else:
     *         nan_value = -np.inf
     *     mask = np.isnan(values)             # <<<<<<<<<<<<<<
     *     np.putmask(values, mask, nan_value)
     *
     */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isnan); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_mask = __pyx_t_1;
      __pyx_t_1 = 0;

     158:     np.putmask(values, mask, nan_value)

      /* "pandas/algos.pyx":158
     *         nan_value = -np.inf
     *     mask = np.isnan(values)
     *     np.putmask(values, mask, nan_value)             # <<<<<<<<<<<<<<
     *
     *     n = len(values)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_putmask); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_nan_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __Pyx_INCREF(__pyx_v_mask);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_mask);
      __Pyx_GIVEREF(__pyx_v_mask);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     159:

     160:     n = len(values)

      /* "pandas/algos.pyx":160
     *     np.putmask(values, mask, nan_value)
     *
     *     n = len(values)             # <<<<<<<<<<<<<<
     *     ranks = np.empty(n, dtype='f8')
     *
     */
      __pyx_t_11 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_11;

     161:     ranks = np.empty(n, dtype='f8')

      /* "pandas/algos.pyx":161
     *
     *     n = len(values)
     *     ranks = np.empty(n, dtype='f8')             # <<<<<<<<<<<<<<
     *
     *     # py2.5/win32 hack, can't pass i8
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_n_s_f8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_v_ranks, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
          }
        }
        __pyx_pybuffernd_ranks.diminfo[0].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ranks.diminfo[0].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __pyx_v_ranks = ((PyArrayObject *)__pyx_t_12);
      __pyx_t_12 = 0;

     162:

     163:     # py2.5/win32 hack, can't pass i8

     164:     if tiebreak == TIEBREAK_FIRST:

      /* "pandas/algos.pyx":164
     *
     *     # py2.5/win32 hack, can't pass i8
     *     if tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *         # need to use a stable sort here
     *         _as = values.argsort(kind='mergesort')
     */
      __pyx_t_9 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
      if (__pyx_t_9) {

     165:         # need to use a stable sort here

     166:         _as = values.argsort(kind='mergesort')

        /* "pandas/algos.pyx":166
     *     if tiebreak == TIEBREAK_FIRST:
     *         # need to use a stable sort here
     *         _as = values.argsort(kind='mergesort')             # <<<<<<<<<<<<<<
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     */
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_kind, __pyx_n_s_mergesort) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = PyObject_Call(__pyx_t_12, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v__as = __pyx_t_4;
        __pyx_t_4 = 0;

     167:         if not ascending:

        /* "pandas/algos.pyx":167
     *         # need to use a stable sort here
     *         _as = values.argsort(kind='mergesort')
     *         if not ascending:             # <<<<<<<<<<<<<<
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     */
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_13 = ((!__pyx_t_9) != 0);
        if (__pyx_t_13) {

     168:             tiebreak = TIEBREAK_FIRST_DESCENDING

          /* "pandas/algos.pyx":168
     *         _as = values.argsort(kind='mergesort')
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING             # <<<<<<<<<<<<<<
     *     else:
     *         _as = values.argsort()
     */
          __pyx_v_tiebreak = __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING;
          goto __pyx_L5;
        }
        __pyx_L5:;
        goto __pyx_L4;
      }
      /*else*/ {

     169:     else:

     170:         _as = values.argsort()

        /* "pandas/algos.pyx":170
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     *         _as = values.argsort()             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v__as = __pyx_t_1;
        __pyx_t_1 = 0;
      }
      __pyx_L4:;

     171:

     172:     if not ascending:

      /* "pandas/algos.pyx":172
     *         _as = values.argsort()
     *
     *     if not ascending:             # <<<<<<<<<<<<<<
     *         _as = _as[::-1]
     *
     */
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = ((!__pyx_t_13) != 0);
      if (__pyx_t_9) {

     173:         _as = _as[::-1]

        /* "pandas/algos.pyx":173
     *
     *     if not ascending:
     *         _as = _as[::-1]             # <<<<<<<<<<<<<<
     *
     *     sorted_data = values.take(_as)
     */
        __pyx_t_1 = PyObject_GetItem(__pyx_v__as, __pyx_slice__2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v__as, __pyx_t_1);
        __pyx_t_1 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "pandas/algos.pyx":173
     *
     *     if not ascending:
     *         _as = _as[::-1]             # <<<<<<<<<<<<<<
     *
     *     sorted_data = values.take(_as)
     */
      __pyx_slice__2 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__2);
      __Pyx_GIVEREF(__pyx_slice__2);

     174:

     175:     sorted_data = values.take(_as)

      /* "pandas/algos.pyx":175
     *         _as = _as[::-1]
     *
     *     sorted_data = values.take(_as)             # <<<<<<<<<<<<<<
     *     argsorted = _as.astype('i8')
     *
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_take); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v__as);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__as);
      __Pyx_GIVEREF(__pyx_v__as);
      __pyx_t_12 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_sorted_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_sorted_data.diminfo[0].strides = __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sorted_data.diminfo[0].shape = __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __pyx_v_sorted_data = ((PyArrayObject *)__pyx_t_12);
      __pyx_t_12 = 0;

     176:     argsorted = _as.astype('i8')

      /* "pandas/algos.pyx":176
     *
     *     sorted_data = values.take(_as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v__as, __pyx_n_s_astype); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_4 = PyObject_Call(__pyx_t_12, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
          }
        }
        __pyx_pybuffernd_argsorted.diminfo[0].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_argsorted.diminfo[0].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_argsorted = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pandas/algos.pyx":176
     *
     *     sorted_data = values.take(_as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__3);
      __Pyx_GIVEREF(__pyx_tuple__3);

     177:

     178:     for i in range(n):

      /* "pandas/algos.pyx":178
     *     argsorted = _as.astype('i8')
     *
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         sum_ranks += i + 1
     *         dups += 1
     */
      __pyx_t_11 = __pyx_v_n;
      for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_11; __pyx_t_15+=1) {
        __pyx_v_i = __pyx_t_15;

     179:         sum_ranks += i + 1

        /* "pandas/algos.pyx":179
     *
     *     for i in range(n):
     *         sum_ranks += i + 1             # <<<<<<<<<<<<<<
     *         dups += 1
     *         val = sorted_data[i]
     */
        __pyx_v_sum_ranks = (__pyx_v_sum_ranks + (__pyx_v_i + 1));

     180:         dups += 1

        /* "pandas/algos.pyx":180
     *     for i in range(n):
     *         sum_ranks += i + 1
     *         dups += 1             # <<<<<<<<<<<<<<
     *         val = sorted_data[i]
     *         if (val == nan_value) and keep_na:
     */
        __pyx_v_dups = (__pyx_v_dups + 1);

     181:         val = sorted_data[i]

        /* "pandas/algos.pyx":181
     *         sum_ranks += i + 1
     *         dups += 1
     *         val = sorted_data[i]             # <<<<<<<<<<<<<<
     *         if (val == nan_value) and keep_na:
     *             ranks[argsorted[i]] = nan
     */
        __pyx_t_16 = __pyx_v_i;
        __pyx_t_3 = -1;
        if (__pyx_t_16 < 0) {
          __pyx_t_16 += __pyx_pybuffernd_sorted_data.diminfo[0].shape;
          if (unlikely(__pyx_t_16 < 0)) __pyx_t_3 = 0;
        } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_sorted_data.diminfo[0].shape)) __pyx_t_3 = 0;
        if (unlikely(__pyx_t_3 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_3);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_sorted_data.diminfo[0].strides));

     182:         if (val == nan_value) and keep_na:

        /* "pandas/algos.pyx":182
     *         dups += 1
     *         val = sorted_data[i]
     *         if (val == nan_value) and keep_na:             # <<<<<<<<<<<<<<
     *             ranks[argsorted[i]] = nan
     *             continue
     */
        __pyx_t_9 = ((__pyx_v_val == __pyx_v_nan_value) != 0);
        if (__pyx_t_9) {
          __pyx_t_13 = (__pyx_v_keep_na != 0);
        } else {
          __pyx_t_13 = __pyx_t_9;
        }
        if (__pyx_t_13) {

     183:             ranks[argsorted[i]] = nan

          /* "pandas/algos.pyx":183
     *         val = sorted_data[i]
     *         if (val == nan_value) and keep_na:
     *             ranks[argsorted[i]] = nan             # <<<<<<<<<<<<<<
     *             continue
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > FP_ERR:
     */
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_3 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_18 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_argsorted.diminfo[0].strides));
          __pyx_t_3 = -1;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_ranks.diminfo[0].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_ranks.diminfo[0].strides) = __pyx_v_6pandas_5algos_nan;

     184:             continue

          /* "pandas/algos.pyx":184
     *         if (val == nan_value) and keep_na:
     *             ranks[argsorted[i]] = nan
     *             continue             # <<<<<<<<<<<<<<
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > FP_ERR:
     *             if tiebreak == TIEBREAK_AVERAGE:
     */
          goto __pyx_L7_continue;
        }

     185:         if i == n - 1 or fabs(sorted_data[i + 1] - val) > FP_ERR:

        /* "pandas/algos.pyx":185
     *             ranks[argsorted[i]] = nan
     *             continue
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > FP_ERR:             # <<<<<<<<<<<<<<
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):
     */
        __pyx_t_13 = ((__pyx_v_i == (__pyx_v_n - 1)) != 0);
        if (!__pyx_t_13) {
          __pyx_t_19 = (__pyx_v_i + 1);
          __pyx_t_3 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_sorted_data.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_sorted_data.diminfo[0].shape)) __pyx_t_3 = 0;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_9 = ((fabs(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_sorted_data.diminfo[0].strides)) - __pyx_v_val)) > __pyx_v_6pandas_5algos_FP_ERR) != 0);
          __pyx_t_20 = __pyx_t_9;
        } else {
          __pyx_t_20 = __pyx_t_13;
        }
        if (__pyx_t_20) {

     186:             if tiebreak == TIEBREAK_AVERAGE:

          /* "pandas/algos.pyx":186
     *             continue
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > FP_ERR:
     *             if tiebreak == TIEBREAK_AVERAGE:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups
     */
          __pyx_t_20 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE) != 0);
          if (__pyx_t_20) {

     187:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":187
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > FP_ERR:
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:
     */
            __pyx_t_21 = (__pyx_v_i + 1);
            for (__pyx_t_22 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
              __pyx_v_j = __pyx_t_22;

     188:                     ranks[argsorted[j]] = sum_ranks / dups

              /* "pandas/algos.pyx":188
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):
     */
              if (unlikely(__pyx_v_dups == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_23 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_23 < 0) {
                __pyx_t_23 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_23 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_24 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_24 < 0) {
                __pyx_t_24 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_24 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_sum_ranks / __pyx_v_dups);
            }
            goto __pyx_L11;
          }

     189:             elif tiebreak == TIEBREAK_MIN:

          /* "pandas/algos.pyx":189
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2
     */
          __pyx_t_20 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MIN) != 0);
          if (__pyx_t_20) {

     190:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":190
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:
     */
            __pyx_t_21 = (__pyx_v_i + 1);
            for (__pyx_t_22 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
              __pyx_v_j = __pyx_t_22;

     191:                     ranks[argsorted[j]] = i - dups + 2

              /* "pandas/algos.pyx":191
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_25 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_25 < 0) {
                __pyx_t_25 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_25 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_26 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_26 < 0) {
                __pyx_t_26 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_26 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_ranks.diminfo[0].strides) = ((__pyx_v_i - __pyx_v_dups) + 2);
            }
            goto __pyx_L11;
          }

     192:             elif tiebreak == TIEBREAK_MAX:

          /* "pandas/algos.pyx":192
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1
     */
          __pyx_t_20 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MAX) != 0);
          if (__pyx_t_20) {

     193:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":193
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     */
            __pyx_t_21 = (__pyx_v_i + 1);
            for (__pyx_t_22 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
              __pyx_v_j = __pyx_t_22;

     194:                     ranks[argsorted[j]] = i + 1

              /* "pandas/algos.pyx":194
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_27 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_27 < 0) {
                __pyx_t_27 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_27 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_28 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_28 < 0) {
                __pyx_t_28 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_28 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_i + 1);
            }
            goto __pyx_L11;
          }

     195:             elif tiebreak == TIEBREAK_FIRST:

          /* "pandas/algos.pyx":195
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = j + 1
     */
          __pyx_t_20 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
          if (__pyx_t_20) {

     196:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":196
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = j + 1
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     */
            __pyx_t_21 = (__pyx_v_i + 1);
            for (__pyx_t_22 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
              __pyx_v_j = __pyx_t_22;

     197:                     ranks[argsorted[j]] = j + 1

              /* "pandas/algos.pyx":197
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = j + 1             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_29 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_29 < 0) {
                __pyx_t_29 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_29 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_30 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_30 < 0) {
                __pyx_t_30 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_30 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_j + 1);
            }
            goto __pyx_L11;
          }

     198:             elif tiebreak == TIEBREAK_FIRST_DESCENDING:

          /* "pandas/algos.pyx":198
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = j + 1
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     */
          __pyx_t_20 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING) != 0);
          if (__pyx_t_20) {

     199:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":199
     *                     ranks[argsorted[j]] = j + 1
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     *             sum_ranks = dups = 0
     */
            __pyx_t_21 = (__pyx_v_i + 1);
            for (__pyx_t_22 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
              __pyx_v_j = __pyx_t_22;

     200:                     ranks[argsorted[j]] = 2 * i - j - dups + 2

              /* "pandas/algos.pyx":200
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2             # <<<<<<<<<<<<<<
     *             sum_ranks = dups = 0
     *     return ranks
     */
              __pyx_t_31 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_31 < 0) {
                __pyx_t_31 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_31 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_32 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_32 < 0) {
                __pyx_t_32 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_32 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_ranks.diminfo[0].strides) = ((((2 * __pyx_v_i) - __pyx_v_j) - __pyx_v_dups) + 2);
            }
            goto __pyx_L11;
          }
          __pyx_L11:;

     201:             sum_ranks = dups = 0

          /* "pandas/algos.pyx":201
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     *             sum_ranks = dups = 0             # <<<<<<<<<<<<<<
     *     return ranks
     *
     */
          __pyx_v_sum_ranks = 0;
          __pyx_v_dups = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        __pyx_L7_continue:;
      }

     202:     return ranks

      /* "pandas/algos.pyx":202
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     *             sum_ranks = dups = 0
     *     return ranks             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
      __pyx_r = ((PyObject *)__pyx_v_ranks);
      goto __pyx_L0;

     203:

     204:

     205: def rank_1d_int64(object in_arr, ties_method='average', ascending=True,

    /* "pandas/algos.pyx":205
     *
     *
     * def rank_1d_int64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                   na_option='keep'):
     *     """
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_3rank_1d_int64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_2rank_1d_int64[] = "\n    Fast NaN-friendly version of scipy.stats.rankdata\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_3rank_1d_int64 = {__Pyx_NAMESTR("rank_1d_int64"), (PyCFunction)__pyx_pw_6pandas_5algos_3rank_1d_int64, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_2rank_1d_int64)};
    static PyObject *__pyx_pw_6pandas_5algos_3rank_1d_int64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_in_arr = 0;
      PyObject *__pyx_v_ties_method = 0;
      PyObject *__pyx_v_ascending = 0;
      CYTHON_UNUSED PyObject *__pyx_v_na_option = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_1d_int64 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_arr,&__pyx_n_s_ties_method,&__pyx_n_s_ascending,&__pyx_n_s_na_option,0};
        PyObject* values[4] = {0,0,0,0};
        values[1] = ((PyObject *)__pyx_n_s_average);
        values[2] = ((PyObject *)Py_True);
        values[3] = ((PyObject *)__pyx_n_s_keep);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arr)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ties_method);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ascending);
              if (value) { values[2] = value; kw_args--; }
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_na_option);
              if (value) { values[3] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rank_1d_int64") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_in_arr = values[0];
        __pyx_v_ties_method = values[1];
        __pyx_v_ascending = values[2];
        __pyx_v_na_option = values[3];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("rank_1d_int64", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.rank_1d_int64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_2rank_1d_int64(__pyx_self, __pyx_v_in_arr, __pyx_v_ties_method, __pyx_v_ascending, __pyx_v_na_option);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_2rank_1d_int64(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_arr, PyObject *__pyx_v_ties_method, PyObject *__pyx_v_ascending, CYTHON_UNUSED PyObject *__pyx_v_na_option) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_dups;
      PyArrayObject *__pyx_v_sorted_data = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_ranks = 0;
      PyArrayObject *__pyx_v_argsorted = 0;
      __pyx_t_5numpy_int64_t __pyx_v_val;
      __pyx_t_5numpy_float64_t __pyx_v_sum_ranks;
      int __pyx_v_tiebreak;
      PyObject *__pyx_v__as = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_argsorted;
      __Pyx_Buffer __pyx_pybuffer_argsorted;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_ranks;
      __Pyx_Buffer __pyx_pybuffer_ranks;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_sorted_data;
      __Pyx_Buffer __pyx_pybuffer_sorted_data;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_1d_int64", 0);
      __pyx_pybuffer_sorted_data.pybuffer.buf = NULL;
      __pyx_pybuffer_sorted_data.refcount = 0;
      __pyx_pybuffernd_sorted_data.data = NULL;
      __pyx_pybuffernd_sorted_data.rcbuffer = &__pyx_pybuffer_sorted_data;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_ranks.pybuffer.buf = NULL;
      __pyx_pybuffer_ranks.refcount = 0;
      __pyx_pybuffernd_ranks.data = NULL;
      __pyx_pybuffernd_ranks.rcbuffer = &__pyx_pybuffer_ranks;
      __pyx_pybuffer_argsorted.pybuffer.buf = NULL;
      __pyx_pybuffer_argsorted.refcount = 0;
      __pyx_pybuffernd_argsorted.data = NULL;
      __pyx_pybuffernd_argsorted.rcbuffer = &__pyx_pybuffer_argsorted;

      /* "pandas/algos.pyx":205
     *
     *
     * def rank_1d_int64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                   na_option='keep'):
     *     """
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_10);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.rank_1d_int64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_sorted_data);
      __Pyx_XDECREF((PyObject *)__pyx_v_values);
      __Pyx_XDECREF((PyObject *)__pyx_v_ranks);
      __Pyx_XDECREF((PyObject *)__pyx_v_argsorted);
      __Pyx_XDECREF(__pyx_v__as);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":205
     *
     *
     * def rank_1d_int64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                   na_option='keep'):
     *     """
     */
      __pyx_tuple__218 = PyTuple_Pack(16, __pyx_n_s_in_arr, __pyx_n_s_ties_method, __pyx_n_s_ascending, __pyx_n_s_na_option, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_n, __pyx_n_s_dups, __pyx_n_s_sorted_data, __pyx_n_s_values, __pyx_n_s_ranks, __pyx_n_s_argsorted, __pyx_n_s_val, __pyx_n_s_sum_ranks, __pyx_n_s_tiebreak, __pyx_n_s_as); if (unlikely(!__pyx_tuple__218)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__218);
      __Pyx_GIVEREF(__pyx_tuple__218);

      /* "pandas/algos.pyx":205
     *
     *
     * def rank_1d_int64(object in_arr, ties_method='average', ascending=True,             # <<<<<<<<<<<<<<
     *                   na_option='keep'):
     *     """
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_3rank_1d_int64, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rank_1d_int64, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__219 = (PyObject*)__Pyx_PyCode_New(4, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__218, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_rank_1d_int64, 205, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__219)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     206:                   na_option='keep'):

     207:     """

     208:     Fast NaN-friendly version of scipy.stats.rankdata

     209:     """

     210:

     211:     cdef:

     212:         Py_ssize_t i, j, n, dups = 0

      /* "pandas/algos.pyx":212
     *
     *     cdef:
     *         Py_ssize_t i, j, n, dups = 0             # <<<<<<<<<<<<<<
     *         ndarray[int64_t] sorted_data, values
     *         ndarray[float64_t] ranks
     */
      __pyx_v_dups = 0;

     213:         ndarray[int64_t] sorted_data, values

     214:         ndarray[float64_t] ranks

     215:         ndarray[int64_t] argsorted

     216:         int64_t val

     217:         float64_t sum_ranks = 0

      /* "pandas/algos.pyx":217
     *         ndarray[int64_t] argsorted
     *         int64_t val
     *         float64_t sum_ranks = 0             # <<<<<<<<<<<<<<
     *         int tiebreak = 0
     *     tiebreak = tiebreakers[ties_method]
     */
      __pyx_v_sum_ranks = 0.0;

     218:         int tiebreak = 0

      /* "pandas/algos.pyx":218
     *         int64_t val
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0             # <<<<<<<<<<<<<<
     *     tiebreak = tiebreakers[ties_method]
     *
     */
      __pyx_v_tiebreak = 0;

     219:     tiebreak = tiebreakers[ties_method]

      /* "pandas/algos.pyx":219
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0
     *     tiebreak = tiebreakers[ties_method]             # <<<<<<<<<<<<<<
     *
     *     values = np.asarray(in_arr)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tiebreakers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_ties_method); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tiebreak = __pyx_t_3;

     220:

     221:     values = np.asarray(in_arr)

      /* "pandas/algos.pyx":221
     *     tiebreak = tiebreakers[ties_method]
     *
     *     values = np.asarray(in_arr)             # <<<<<<<<<<<<<<
     *
     *     n = len(values)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_in_arr);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
      __Pyx_GIVEREF(__pyx_v_in_arr);
      __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __pyx_v_values = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

     222:

     223:     n = len(values)

      /* "pandas/algos.pyx":223
     *     values = np.asarray(in_arr)
     *
     *     n = len(values)             # <<<<<<<<<<<<<<
     *     ranks = np.empty(n, dtype='f8')
     *
     */
      __pyx_t_9 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_9;

     224:     ranks = np.empty(n, dtype='f8')

      /* "pandas/algos.pyx":224
     *
     *     n = len(values)
     *     ranks = np.empty(n, dtype='f8')             # <<<<<<<<<<<<<<
     *
     *     # py2.5/win32 hack, can't pass i8
     */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_n_s_f8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_v_ranks, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
          }
        }
        __pyx_pybuffernd_ranks.diminfo[0].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ranks.diminfo[0].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = 0;
      __pyx_v_ranks = ((PyArrayObject *)__pyx_t_10);
      __pyx_t_10 = 0;

     225:

     226:     # py2.5/win32 hack, can't pass i8

     227:     if tiebreak == TIEBREAK_FIRST:

      /* "pandas/algos.pyx":227
     *
     *     # py2.5/win32 hack, can't pass i8
     *     if tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *         # need to use a stable sort here
     *         _as = values.argsort(kind='mergesort')
     */
      __pyx_t_12 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
      if (__pyx_t_12) {

     228:         # need to use a stable sort here

     229:         _as = values.argsort(kind='mergesort')

        /* "pandas/algos.pyx":229
     *     if tiebreak == TIEBREAK_FIRST:
     *         # need to use a stable sort here
     *         _as = values.argsort(kind='mergesort')             # <<<<<<<<<<<<<<
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     */
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_kind, __pyx_n_s_mergesort) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = PyObject_Call(__pyx_t_10, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v__as = __pyx_t_1;
        __pyx_t_1 = 0;

     230:         if not ascending:

        /* "pandas/algos.pyx":230
     *         # need to use a stable sort here
     *         _as = values.argsort(kind='mergesort')
     *         if not ascending:             # <<<<<<<<<<<<<<
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     */
        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_13 = ((!__pyx_t_12) != 0);
        if (__pyx_t_13) {

     231:             tiebreak = TIEBREAK_FIRST_DESCENDING

          /* "pandas/algos.pyx":231
     *         _as = values.argsort(kind='mergesort')
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING             # <<<<<<<<<<<<<<
     *     else:
     *         _as = values.argsort()
     */
          __pyx_v_tiebreak = __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING;
          goto __pyx_L4;
        }
        __pyx_L4:;
        goto __pyx_L3;
      }
      /*else*/ {

     232:     else:

     233:         _as = values.argsort()

        /* "pandas/algos.pyx":233
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     *         _as = values.argsort()             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v__as = __pyx_t_4;
        __pyx_t_4 = 0;
      }
      __pyx_L3:;

     234:

     235:     if not ascending:

      /* "pandas/algos.pyx":235
     *         _as = values.argsort()
     *
     *     if not ascending:             # <<<<<<<<<<<<<<
     *         _as = _as[::-1]
     *
     */
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = ((!__pyx_t_13) != 0);
      if (__pyx_t_12) {

     236:         _as = _as[::-1]

        /* "pandas/algos.pyx":236
     *
     *     if not ascending:
     *         _as = _as[::-1]             # <<<<<<<<<<<<<<
     *
     *     sorted_data = values.take(_as)
     */
        __pyx_t_4 = PyObject_GetItem(__pyx_v__as, __pyx_slice__4); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v__as, __pyx_t_4);
        __pyx_t_4 = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "pandas/algos.pyx":236
     *
     *     if not ascending:
     *         _as = _as[::-1]             # <<<<<<<<<<<<<<
     *
     *     sorted_data = values.take(_as)
     */
      __pyx_slice__4 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__4);
      __Pyx_GIVEREF(__pyx_slice__4);

     237:

     238:     sorted_data = values.take(_as)

      /* "pandas/algos.pyx":238
     *         _as = _as[::-1]
     *
     *     sorted_data = values.take(_as)             # <<<<<<<<<<<<<<
     *     argsorted = _as.astype('i8')
     *
     */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_take); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v__as);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__as);
      __Pyx_GIVEREF(__pyx_v__as);
      __pyx_t_10 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sorted_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_sorted_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_sorted_data.diminfo[0].strides = __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sorted_data.diminfo[0].shape = __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __pyx_v_sorted_data = ((PyArrayObject *)__pyx_t_10);
      __pyx_t_10 = 0;

     239:     argsorted = _as.astype('i8')

      /* "pandas/algos.pyx":239
     *
     *     sorted_data = values.take(_as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v__as, __pyx_n_s_astype); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = PyObject_Call(__pyx_t_10, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
          }
        }
        __pyx_pybuffernd_argsorted.diminfo[0].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_argsorted.diminfo[0].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_argsorted = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "pandas/algos.pyx":239
     *
     *     sorted_data = values.take(_as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__5);
      __Pyx_GIVEREF(__pyx_tuple__5);

     240:

     241:     for i in range(n):

      /* "pandas/algos.pyx":241
     *     argsorted = _as.astype('i8')
     *
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         sum_ranks += i + 1
     *         dups += 1
     */
      __pyx_t_9 = __pyx_v_n;
      for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_9; __pyx_t_15+=1) {
        __pyx_v_i = __pyx_t_15;

     242:         sum_ranks += i + 1

        /* "pandas/algos.pyx":242
     *
     *     for i in range(n):
     *         sum_ranks += i + 1             # <<<<<<<<<<<<<<
     *         dups += 1
     *         val = sorted_data[i]
     */
        __pyx_v_sum_ranks = (__pyx_v_sum_ranks + (__pyx_v_i + 1));

     243:         dups += 1

        /* "pandas/algos.pyx":243
     *     for i in range(n):
     *         sum_ranks += i + 1
     *         dups += 1             # <<<<<<<<<<<<<<
     *         val = sorted_data[i]
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > 0:
     */
        __pyx_v_dups = (__pyx_v_dups + 1);

     244:         val = sorted_data[i]

        /* "pandas/algos.pyx":244
     *         sum_ranks += i + 1
     *         dups += 1
     *         val = sorted_data[i]             # <<<<<<<<<<<<<<
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > 0:
     *             if tiebreak == TIEBREAK_AVERAGE:
     */
        __pyx_t_16 = __pyx_v_i;
        __pyx_t_3 = -1;
        if (__pyx_t_16 < 0) {
          __pyx_t_16 += __pyx_pybuffernd_sorted_data.diminfo[0].shape;
          if (unlikely(__pyx_t_16 < 0)) __pyx_t_3 = 0;
        } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_sorted_data.diminfo[0].shape)) __pyx_t_3 = 0;
        if (unlikely(__pyx_t_3 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_3);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_sorted_data.diminfo[0].strides));

     245:         if i == n - 1 or fabs(sorted_data[i + 1] - val) > 0:

        /* "pandas/algos.pyx":245
     *         dups += 1
     *         val = sorted_data[i]
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > 0:             # <<<<<<<<<<<<<<
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):
     */
        __pyx_t_12 = ((__pyx_v_i == (__pyx_v_n - 1)) != 0);
        if (!__pyx_t_12) {
          __pyx_t_17 = (__pyx_v_i + 1);
          __pyx_t_3 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_sorted_data.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_sorted_data.diminfo[0].shape)) __pyx_t_3 = 0;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_13 = ((fabs(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_sorted_data.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_sorted_data.diminfo[0].strides)) - __pyx_v_val)) > 0.0) != 0);
          __pyx_t_18 = __pyx_t_13;
        } else {
          __pyx_t_18 = __pyx_t_12;
        }
        if (__pyx_t_18) {

     246:             if tiebreak == TIEBREAK_AVERAGE:

          /* "pandas/algos.pyx":246
     *         val = sorted_data[i]
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > 0:
     *             if tiebreak == TIEBREAK_AVERAGE:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups
     */
          __pyx_t_18 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE) != 0);
          if (__pyx_t_18) {

     247:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":247
     *         if i == n - 1 or fabs(sorted_data[i + 1] - val) > 0:
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:
     */
            __pyx_t_19 = (__pyx_v_i + 1);
            for (__pyx_t_20 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
              __pyx_v_j = __pyx_t_20;

     248:                     ranks[argsorted[j]] = sum_ranks / dups

              /* "pandas/algos.pyx":248
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):
     */
              if (unlikely(__pyx_v_dups == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_21 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_21 < 0) {
                __pyx_t_21 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_21 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_22 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_22 < 0) {
                __pyx_t_22 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_22 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_sum_ranks / __pyx_v_dups);
            }
            goto __pyx_L9;
          }

     249:             elif tiebreak == TIEBREAK_MIN:

          /* "pandas/algos.pyx":249
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2
     */
          __pyx_t_18 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MIN) != 0);
          if (__pyx_t_18) {

     250:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":250
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:
     */
            __pyx_t_19 = (__pyx_v_i + 1);
            for (__pyx_t_20 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
              __pyx_v_j = __pyx_t_20;

     251:                     ranks[argsorted[j]] = i - dups + 2

              /* "pandas/algos.pyx":251
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_23 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_23 < 0) {
                __pyx_t_23 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_23 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_24 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_24 < 0) {
                __pyx_t_24 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_24 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_ranks.diminfo[0].strides) = ((__pyx_v_i - __pyx_v_dups) + 2);
            }
            goto __pyx_L9;
          }

     252:             elif tiebreak == TIEBREAK_MAX:

          /* "pandas/algos.pyx":252
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1
     */
          __pyx_t_18 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MAX) != 0);
          if (__pyx_t_18) {

     253:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":253
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     */
            __pyx_t_19 = (__pyx_v_i + 1);
            for (__pyx_t_20 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
              __pyx_v_j = __pyx_t_20;

     254:                     ranks[argsorted[j]] = i + 1

              /* "pandas/algos.pyx":254
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_25 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_25 < 0) {
                __pyx_t_25 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_25 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_26 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_26 < 0) {
                __pyx_t_26 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_26 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_i + 1);
            }
            goto __pyx_L9;
          }

     255:             elif tiebreak == TIEBREAK_FIRST:

          /* "pandas/algos.pyx":255
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = j + 1
     */
          __pyx_t_18 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
          if (__pyx_t_18) {

     256:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":256
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = j + 1
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     */
            __pyx_t_19 = (__pyx_v_i + 1);
            for (__pyx_t_20 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
              __pyx_v_j = __pyx_t_20;

     257:                     ranks[argsorted[j]] = j + 1

              /* "pandas/algos.pyx":257
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = j + 1             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_27 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_27 < 0) {
                __pyx_t_27 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_27 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_28 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_28 < 0) {
                __pyx_t_28 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_28 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_j + 1);
            }
            goto __pyx_L9;
          }

     258:             elif tiebreak == TIEBREAK_FIRST_DESCENDING:

          /* "pandas/algos.pyx":258
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = j + 1
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     */
          __pyx_t_18 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING) != 0);
          if (__pyx_t_18) {

     259:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":259
     *                     ranks[argsorted[j]] = j + 1
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     *             sum_ranks = dups = 0
     */
            __pyx_t_19 = (__pyx_v_i + 1);
            for (__pyx_t_20 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
              __pyx_v_j = __pyx_t_20;

     260:                     ranks[argsorted[j]] = 2 * i - j - dups + 2

              /* "pandas/algos.pyx":260
     *             elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2             # <<<<<<<<<<<<<<
     *             sum_ranks = dups = 0
     *     return ranks
     */
              __pyx_t_29 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_29 < 0) {
                __pyx_t_29 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_29 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_30 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_30 < 0) {
                __pyx_t_30 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_30 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_ranks.diminfo[0].strides) = ((((2 * __pyx_v_i) - __pyx_v_j) - __pyx_v_dups) + 2);
            }
            goto __pyx_L9;
          }
          __pyx_L9:;

     261:             sum_ranks = dups = 0

          /* "pandas/algos.pyx":261
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     *             sum_ranks = dups = 0             # <<<<<<<<<<<<<<
     *     return ranks
     *
     */
          __pyx_v_sum_ranks = 0;
          __pyx_v_dups = 0;
          goto __pyx_L8;
        }
        __pyx_L8:;
      }

     262:     return ranks

      /* "pandas/algos.pyx":262
     *                     ranks[argsorted[j]] = 2 * i - j - dups + 2
     *             sum_ranks = dups = 0
     *     return ranks             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
      __pyx_r = ((PyObject *)__pyx_v_ranks);
      goto __pyx_L0;

     263:

     264:

     265: def rank_2d_float64(object in_arr, axis=0, ties_method='average',

    /* "pandas/algos.pyx":265
     *
     *
     * def rank_2d_float64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_5rank_2d_float64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_4rank_2d_float64[] = "\n    Fast NaN-friendly version of scipy.stats.rankdata\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_5rank_2d_float64 = {__Pyx_NAMESTR("rank_2d_float64"), (PyCFunction)__pyx_pw_6pandas_5algos_5rank_2d_float64, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_4rank_2d_float64)};
    static PyObject *__pyx_pw_6pandas_5algos_5rank_2d_float64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_in_arr = 0;
      PyObject *__pyx_v_axis = 0;
      PyObject *__pyx_v_ties_method = 0;
      PyObject *__pyx_v_ascending = 0;
      PyObject *__pyx_v_na_option = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_2d_float64 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_arr,&__pyx_n_s_axis,&__pyx_n_s_ties_method,&__pyx_n_s_ascending,&__pyx_n_s_na_option,0};
        PyObject* values[5] = {0,0,0,0,0};
        values[1] = ((PyObject *)__pyx_int_0);
        values[2] = ((PyObject *)__pyx_n_s_average);

      /* "pandas/algos.pyx":265
     *
     *
     * def rank_2d_float64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_4rank_2d_float64(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_arr, PyObject *__pyx_v_axis, PyObject *__pyx_v_ties_method, PyObject *__pyx_v_ascending, PyObject *__pyx_v_na_option) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_z;
      Py_ssize_t __pyx_v_k;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_dups;
      PyArrayObject *__pyx_v_ranks = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_argsorted = 0;
      __pyx_t_5numpy_float64_t __pyx_v_val;
      __pyx_t_5numpy_float64_t __pyx_v_nan_value;
      __pyx_t_5numpy_float64_t __pyx_v_sum_ranks;
      int __pyx_v_tiebreak;
      int __pyx_v_keep_na;
      PyObject *__pyx_v__as = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_argsorted;
      __Pyx_Buffer __pyx_pybuffer_argsorted;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_ranks;
      __Pyx_Buffer __pyx_pybuffer_ranks;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_2d_float64", 0);
      __Pyx_INCREF(__pyx_v_in_arr);
      __pyx_pybuffer_ranks.pybuffer.buf = NULL;
      __pyx_pybuffer_ranks.refcount = 0;
      __pyx_pybuffernd_ranks.data = NULL;
      __pyx_pybuffernd_ranks.rcbuffer = &__pyx_pybuffer_ranks;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_argsorted.pybuffer.buf = NULL;
      __pyx_pybuffer_argsorted.refcount = 0;
      __pyx_pybuffernd_argsorted.data = NULL;
      __pyx_pybuffernd_argsorted.rcbuffer = &__pyx_pybuffer_argsorted;

      /* "pandas/algos.pyx":265
     *
     *
     * def rank_2d_float64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_11);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.rank_2d_float64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_ranks);
      __Pyx_XDECREF((PyObject *)__pyx_v_values);
      __Pyx_XDECREF((PyObject *)__pyx_v_argsorted);
      __Pyx_XDECREF(__pyx_v__as);
      __Pyx_XDECREF(__pyx_v_in_arr);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":265
     *
     *
     * def rank_2d_float64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_tuple__220 = PyTuple_Pack(20, __pyx_n_s_in_arr, __pyx_n_s_axis, __pyx_n_s_ties_method, __pyx_n_s_ascending, __pyx_n_s_na_option, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_z, __pyx_n_s_k, __pyx_n_s_n, __pyx_n_s_dups, __pyx_n_s_ranks, __pyx_n_s_values, __pyx_n_s_argsorted, __pyx_n_s_val, __pyx_n_s_nan_value, __pyx_n_s_sum_ranks, __pyx_n_s_tiebreak, __pyx_n_s_keep_na, __pyx_n_s_as); if (unlikely(!__pyx_tuple__220)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__220);
      __Pyx_GIVEREF(__pyx_tuple__220);

      /* "pandas/algos.pyx":265
     *
     *
     * def rank_2d_float64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_5rank_2d_float64, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rank_2d_float64, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__221 = (PyObject*)__Pyx_PyCode_New(5, 0, 20, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__220, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_rank_2d_float64, 265, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__221)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     266:                     ascending=True, na_option='keep'):

        /* "pandas/algos.pyx":266
     *
     * def rank_2d_float64(object in_arr, axis=0, ties_method='average',
     *                     ascending=True, na_option='keep'):             # <<<<<<<<<<<<<<
     *     """
     *     Fast NaN-friendly version of scipy.stats.rankdata
     */
        values[3] = ((PyObject *)Py_True);
        values[4] = ((PyObject *)__pyx_n_s_keep);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arr)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ties_method);
              if (value) { values[2] = value; kw_args--; }
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ascending);
              if (value) { values[3] = value; kw_args--; }
            }
            case  4:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_na_option);
              if (value) { values[4] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rank_2d_float64") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_in_arr = values[0];
        __pyx_v_axis = values[1];
        __pyx_v_ties_method = values[2];
        __pyx_v_ascending = values[3];
        __pyx_v_na_option = values[4];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("rank_2d_float64", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.rank_2d_float64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_4rank_2d_float64(__pyx_self, __pyx_v_in_arr, __pyx_v_axis, __pyx_v_ties_method, __pyx_v_ascending, __pyx_v_na_option);

     267:     """

     268:     Fast NaN-friendly version of scipy.stats.rankdata

     269:     """

     270:

     271:     cdef:

     272:         Py_ssize_t i, j, z, k, n, dups = 0

      /* "pandas/algos.pyx":272
     *
     *     cdef:
     *         Py_ssize_t i, j, z, k, n, dups = 0             # <<<<<<<<<<<<<<
     *         ndarray[float64_t, ndim=2] ranks, values
     *         ndarray[int64_t, ndim=2] argsorted
     */
      __pyx_v_dups = 0;

     273:         ndarray[float64_t, ndim=2] ranks, values

     274:         ndarray[int64_t, ndim=2] argsorted

     275:         float64_t val, nan_value

     276:         float64_t sum_ranks = 0

      /* "pandas/algos.pyx":276
     *         ndarray[int64_t, ndim=2] argsorted
     *         float64_t val, nan_value
     *         float64_t sum_ranks = 0             # <<<<<<<<<<<<<<
     *         int tiebreak = 0
     *         bint keep_na = 0
     */
      __pyx_v_sum_ranks = 0.0;

     277:         int tiebreak = 0

      /* "pandas/algos.pyx":277
     *         float64_t val, nan_value
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0             # <<<<<<<<<<<<<<
     *         bint keep_na = 0
     *
     */
      __pyx_v_tiebreak = 0;

     278:         bint keep_na = 0

      /* "pandas/algos.pyx":278
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0
     *         bint keep_na = 0             # <<<<<<<<<<<<<<
     *
     *     tiebreak = tiebreakers[ties_method]
     */
      __pyx_v_keep_na = 0;

     279:

     280:     tiebreak = tiebreakers[ties_method]

      /* "pandas/algos.pyx":280
     *         bint keep_na = 0
     *
     *     tiebreak = tiebreakers[ties_method]             # <<<<<<<<<<<<<<
     *
     *     keep_na = na_option == 'keep'
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tiebreakers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_ties_method); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tiebreak = __pyx_t_3;

     281:

     282:     keep_na = na_option == 'keep'

      /* "pandas/algos.pyx":282
     *     tiebreak = tiebreakers[ties_method]
     *
     *     keep_na = na_option == 'keep'             # <<<<<<<<<<<<<<
     *
     *     in_arr = np.asarray(in_arr)
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_keep, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_keep_na = __pyx_t_4;

     283:

     284:     in_arr = np.asarray(in_arr)

      /* "pandas/algos.pyx":284
     *     keep_na = na_option == 'keep'
     *
     *     in_arr = np.asarray(in_arr)             # <<<<<<<<<<<<<<
     *
     *     if axis == 0:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_in_arr);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
      __Pyx_GIVEREF(__pyx_v_in_arr);
      __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_in_arr, __pyx_t_5);
      __pyx_t_5 = 0;

     285:

     286:     if axis == 0:

      /* "pandas/algos.pyx":286
     *     in_arr = np.asarray(in_arr)
     *
     *     if axis == 0:             # <<<<<<<<<<<<<<
     *         values = in_arr.T.copy()
     *     else:
     */
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     287:         values = in_arr.T.copy()

        /* "pandas/algos.pyx":287
     *
     *     if axis == 0:
     *         values = in_arr.T.copy()             # <<<<<<<<<<<<<<
     *     else:
     *         values = in_arr.copy()
     */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_in_arr, __pyx_n_s_T); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_values = ((PyArrayObject *)__pyx_t_5);
        __pyx_t_5 = 0;
        goto __pyx_L3;
      }
      /*else*/ {

     288:     else:

     289:         values = in_arr.copy()

        /* "pandas/algos.pyx":289
     *         values = in_arr.T.copy()
     *     else:
     *         values = in_arr.copy()             # <<<<<<<<<<<<<<
     *
     *     if ascending ^ (na_option == 'top'):
     */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_in_arr, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_values = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
      }
      __pyx_L3:;

     290:

     291:     if ascending ^ (na_option == 'top'):

      /* "pandas/algos.pyx":291
     *         values = in_arr.copy()
     *
     *     if ascending ^ (na_option == 'top'):             # <<<<<<<<<<<<<<
     *         nan_value = np.inf
     *     else:
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_top, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyNumber_Xor(__pyx_v_ascending, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     292:         nan_value = np.inf

        /* "pandas/algos.pyx":292
     *
     *     if ascending ^ (na_option == 'top'):
     *         nan_value = np.inf             # <<<<<<<<<<<<<<
     *     else:
     *         nan_value = -np.inf
     */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_nan_value = __pyx_t_10;
        goto __pyx_L4;
      }
      /*else*/ {

     293:     else:

     294:         nan_value = -np.inf

        /* "pandas/algos.pyx":294
     *         nan_value = np.inf
     *     else:
     *         nan_value = -np.inf             # <<<<<<<<<<<<<<
     *
     *     np.putmask(values, np.isnan(values), nan_value)
     */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_inf); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_Negative(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_nan_value = __pyx_t_10;
      }
      __pyx_L4:;

     295:

     296:     np.putmask(values, np.isnan(values), nan_value)

      /* "pandas/algos.pyx":296
     *         nan_value = -np.inf
     *
     *     np.putmask(values, np.isnan(values), nan_value)             # <<<<<<<<<<<<<<
     *
     *     n, k = (<object> values).shape
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_putmask); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isnan); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_11 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_nan_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_11 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     297:

     298:     n, k = (<object> values).shape

      /* "pandas/algos.pyx":298
     *     np.putmask(values, np.isnan(values), nan_value)
     *
     *     n, k = (<object> values).shape             # <<<<<<<<<<<<<<
     *     ranks = np.empty((n, k), dtype='f8')
     *
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_1 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 1; __pyx_t_5 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L6_unpacking_done:;
      }
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_n = __pyx_t_13;
      __pyx_v_k = __pyx_t_14;

     299:     ranks = np.empty((n, k), dtype='f8')

      /* "pandas/algos.pyx":299
     *
     *     n, k = (<object> values).shape
     *     ranks = np.empty((n, k), dtype='f8')             # <<<<<<<<<<<<<<
     *
     *     if tiebreak == TIEBREAK_FIRST:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_n_s_f8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_v_ranks, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          }
        }
        __pyx_pybuffernd_ranks.diminfo[0].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ranks.diminfo[0].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ranks.diminfo[1].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ranks.diminfo[1].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_ranks = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     300:

     301:     if tiebreak == TIEBREAK_FIRST:

      /* "pandas/algos.pyx":301
     *     ranks = np.empty((n, k), dtype='f8')
     *
     *     if tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *         # need to use a stable sort here
     *         _as = values.argsort(axis=1, kind='mergesort')
     */
      __pyx_t_4 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
      if (__pyx_t_4) {

     302:         # need to use a stable sort here

     303:         _as = values.argsort(axis=1, kind='mergesort')

        /* "pandas/algos.pyx":303
     *     if tiebreak == TIEBREAK_FIRST:
     *         # need to use a stable sort here
     *         _as = values.argsort(axis=1, kind='mergesort')             # <<<<<<<<<<<<<<
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_axis, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_kind, __pyx_n_s_mergesort) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_v__as = __pyx_t_1;
        __pyx_t_1 = 0;

     304:         if not ascending:

        /* "pandas/algos.pyx":304
     *         # need to use a stable sort here
     *         _as = values.argsort(axis=1, kind='mergesort')
     *         if not ascending:             # <<<<<<<<<<<<<<
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     */
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_15 = ((!__pyx_t_4) != 0);
        if (__pyx_t_15) {

     305:             tiebreak = TIEBREAK_FIRST_DESCENDING

          /* "pandas/algos.pyx":305
     *         _as = values.argsort(axis=1, kind='mergesort')
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING             # <<<<<<<<<<<<<<
     *     else:
     *         _as = values.argsort(1)
     */
          __pyx_v_tiebreak = __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING;
          goto __pyx_L8;
        }
        __pyx_L8:;
        goto __pyx_L7;
      }
      /*else*/ {

     306:     else:

     307:         _as = values.argsort(1)

        /* "pandas/algos.pyx":307
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     *         _as = values.argsort(1)             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_11 = PyObject_Call(__pyx_t_1, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v__as = __pyx_t_11;
        __pyx_t_11 = 0;
      }
      __pyx_L7:;

      /* "pandas/algos.pyx":307
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     *         _as = values.argsort(1)             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
      __pyx_tuple__6 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__6);
      __Pyx_GIVEREF(__pyx_tuple__6);

     308:

     309:     if not ascending:

      /* "pandas/algos.pyx":309
     *         _as = values.argsort(1)
     *
     *     if not ascending:             # <<<<<<<<<<<<<<
     *         _as = _as[:, ::-1]
     *
     */
      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = ((!__pyx_t_15) != 0);
      if (__pyx_t_4) {

     310:         _as = _as[:, ::-1]

      /* "pandas/algos.pyx":310
     *
     *     if not ascending:
     *         _as = _as[:, ::-1]             # <<<<<<<<<<<<<<
     *
     *     values = _take_2d_float64(values, _as)
     */
      __pyx_slice__7 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__7);
      __Pyx_GIVEREF(__pyx_slice__7);
      __pyx_slice__8 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__8);
      __Pyx_GIVEREF(__pyx_slice__8);

        /* "pandas/algos.pyx":310
     *
     *     if not ascending:
     *         _as = _as[:, ::-1]             # <<<<<<<<<<<<<<
     *
     *     values = _take_2d_float64(values, _as)
     */
        __pyx_t_11 = PyObject_GetItem(__pyx_v__as, __pyx_tuple__9); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF_SET(__pyx_v__as, __pyx_t_11);
        __pyx_t_11 = 0;
        goto __pyx_L9;
      }
      __pyx_L9:;
      __pyx_tuple__9 = PyTuple_Pack(2, __pyx_slice__7, __pyx_slice__8); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__9);
      __Pyx_GIVEREF(__pyx_tuple__9);

     311:

     312:     values = _take_2d_float64(values, _as)

      /* "pandas/algos.pyx":312
     *         _as = _as[:, ::-1]
     *
     *     values = _take_2d_float64(values, _as)             # <<<<<<<<<<<<<<
     *     argsorted = _as.astype('i8')
     *
     */
      __pyx_t_11 = __pyx_f_6pandas_5algos__take_2d_float64(((PyArrayObject *)__pyx_v_values), __pyx_v__as); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_11);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
          }
        }
        __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_values, ((PyArrayObject *)__pyx_t_11));
      __pyx_t_11 = 0;

     313:     argsorted = _as.astype('i8')

      /* "pandas/algos.pyx":313
     *
     *     values = _take_2d_float64(values, _as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v__as, __pyx_n_s_astype); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_1 = PyObject_Call(__pyx_t_11, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          }
        }
        __pyx_pybuffernd_argsorted.diminfo[0].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_argsorted.diminfo[0].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_argsorted.diminfo[1].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_argsorted.diminfo[1].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_16 = 0;
      __pyx_v_argsorted = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "pandas/algos.pyx":313
     *
     *     values = _take_2d_float64(values, _as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__10);
      __Pyx_GIVEREF(__pyx_tuple__10);

     314:

     315:     for i in range(n):

      /* "pandas/algos.pyx":315
     *     argsorted = _as.astype('i8')
     *
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         dups = sum_ranks = 0
     *         for j in range(k):
     */
      __pyx_t_14 = __pyx_v_n;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_14; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

     316:         dups = sum_ranks = 0

        /* "pandas/algos.pyx":316
     *
     *     for i in range(n):
     *         dups = sum_ranks = 0             # <<<<<<<<<<<<<<
     *         for j in range(k):
     *             sum_ranks += j + 1
     */
        __pyx_v_dups = 0;
        __pyx_v_sum_ranks = 0;

     317:         for j in range(k):

        /* "pandas/algos.pyx":317
     *     for i in range(n):
     *         dups = sum_ranks = 0
     *         for j in range(k):             # <<<<<<<<<<<<<<
     *             sum_ranks += j + 1
     *             dups += 1
     */
        __pyx_t_17 = __pyx_v_k;
        for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
          __pyx_v_j = __pyx_t_18;

     318:             sum_ranks += j + 1

          /* "pandas/algos.pyx":318
     *         dups = sum_ranks = 0
     *         for j in range(k):
     *             sum_ranks += j + 1             # <<<<<<<<<<<<<<
     *             dups += 1
     *             val = values[i, j]
     */
          __pyx_v_sum_ranks = (__pyx_v_sum_ranks + (__pyx_v_j + 1));

     319:             dups += 1

          /* "pandas/algos.pyx":319
     *         for j in range(k):
     *             sum_ranks += j + 1
     *             dups += 1             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *             if val == nan_value and keep_na:
     */
          __pyx_v_dups = (__pyx_v_dups + 1);

     320:             val = values[i, j]

          /* "pandas/algos.pyx":320
     *             sum_ranks += j + 1
     *             dups += 1
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *             if val == nan_value and keep_na:
     *                 ranks[i, argsorted[i, j]] = nan
     */
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_20 = __pyx_v_j;
          __pyx_t_3 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_values.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_3 = 0;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_values.diminfo[1].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_3 = 1;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_3 = 1;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_val = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_values.diminfo[1].strides));

     321:             if val == nan_value and keep_na:

          /* "pandas/algos.pyx":321
     *             dups += 1
     *             val = values[i, j]
     *             if val == nan_value and keep_na:             # <<<<<<<<<<<<<<
     *                 ranks[i, argsorted[i, j]] = nan
     *                 continue
     */
          __pyx_t_4 = ((__pyx_v_val == __pyx_v_nan_value) != 0);
          if (__pyx_t_4) {
            __pyx_t_15 = (__pyx_v_keep_na != 0);
          } else {
            __pyx_t_15 = __pyx_t_4;
          }
          if (__pyx_t_15) {

     322:                 ranks[i, argsorted[i, j]] = nan

            /* "pandas/algos.pyx":322
     *             val = values[i, j]
     *             if val == nan_value and keep_na:
     *                 ranks[i, argsorted[i, j]] = nan             # <<<<<<<<<<<<<<
     *                 continue
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     */
            __pyx_t_21 = __pyx_v_i;
            __pyx_t_22 = __pyx_v_j;
            __pyx_t_3 = -1;
            if (__pyx_t_21 < 0) {
              __pyx_t_21 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
              if (unlikely(__pyx_t_21 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_22 < 0) {
              __pyx_t_22 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
              if (unlikely(__pyx_t_22 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_23 = __pyx_v_i;
            __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_argsorted.diminfo[1].strides));
            __pyx_t_3 = -1;
            if (__pyx_t_23 < 0) {
              __pyx_t_23 += __pyx_pybuffernd_ranks.diminfo[0].shape;
              if (unlikely(__pyx_t_23 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_24 < 0) {
              __pyx_t_24 += __pyx_pybuffernd_ranks.diminfo[1].shape;
              if (unlikely(__pyx_t_24 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_ranks.diminfo[1].strides) = __pyx_v_6pandas_5algos_nan;

     323:                 continue

            /* "pandas/algos.pyx":323
     *             if val == nan_value and keep_na:
     *                 ranks[i, argsorted[i, j]] = nan
     *                 continue             # <<<<<<<<<<<<<<
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     *                 if tiebreak == TIEBREAK_AVERAGE:
     */
            goto __pyx_L12_continue;
          }

     324:             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:

          /* "pandas/algos.pyx":324
     *                 ranks[i, argsorted[i, j]] = nan
     *                 continue
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:             # <<<<<<<<<<<<<<
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):
     */
          __pyx_t_15 = ((__pyx_v_j == (__pyx_v_k - 1)) != 0);
          if (!__pyx_t_15) {
            __pyx_t_25 = __pyx_v_i;
            __pyx_t_26 = (__pyx_v_j + 1);
            __pyx_t_3 = -1;
            if (__pyx_t_25 < 0) {
              __pyx_t_25 += __pyx_pybuffernd_values.diminfo[0].shape;
              if (unlikely(__pyx_t_25 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_26 < 0) {
              __pyx_t_26 += __pyx_pybuffernd_values.diminfo[1].shape;
              if (unlikely(__pyx_t_26 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_4 = ((fabs(((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_values.diminfo[1].strides)) - __pyx_v_val)) > __pyx_v_6pandas_5algos_FP_ERR) != 0);
            __pyx_t_27 = __pyx_t_4;
          } else {
            __pyx_t_27 = __pyx_t_15;
          }
          if (__pyx_t_27) {

     325:                 if tiebreak == TIEBREAK_AVERAGE:

            /* "pandas/algos.pyx":325
     *                 continue
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     *                 if tiebreak == TIEBREAK_AVERAGE:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     */
            __pyx_t_27 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE) != 0);
            if (__pyx_t_27) {

     326:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":326
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:
     */
              __pyx_t_28 = (__pyx_v_j + 1);
              for (__pyx_t_29 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
                __pyx_v_z = __pyx_t_29;

     327:                         ranks[i, argsorted[i, z]] = sum_ranks / dups

                /* "pandas/algos.pyx":327
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):
     */
                if (unlikely(__pyx_v_dups == 0)) {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                  #endif
                  PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                  #ifdef WITH_THREAD
                  PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_30 = __pyx_v_i;
                __pyx_t_31 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_30 < 0) {
                  __pyx_t_30 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_30 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_31 < 0) {
                  __pyx_t_31 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_31 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_32 = __pyx_v_i;
                __pyx_t_33 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_32 < 0) {
                  __pyx_t_32 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_32 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_33 < 0) {
                  __pyx_t_33 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_33 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_sum_ranks / __pyx_v_dups);
              }
              goto __pyx_L16;
            }

     328:                 elif tiebreak == TIEBREAK_MIN:

            /* "pandas/algos.pyx":328
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     */
            __pyx_t_27 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MIN) != 0);
            if (__pyx_t_27) {

     329:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":329
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:
     */
              __pyx_t_28 = (__pyx_v_j + 1);
              for (__pyx_t_29 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
                __pyx_v_z = __pyx_t_29;

     330:                         ranks[i, argsorted[i, z]] = j - dups + 2

                /* "pandas/algos.pyx":330
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_34 = __pyx_v_i;
                __pyx_t_35 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_34 < 0) {
                  __pyx_t_34 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_34 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_34 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_35 < 0) {
                  __pyx_t_35 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_35 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_36 = __pyx_v_i;
                __pyx_t_37 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_36 < 0) {
                  __pyx_t_36 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_36 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_36 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_37 < 0) {
                  __pyx_t_37 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_37 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_ranks.diminfo[1].strides) = ((__pyx_v_j - __pyx_v_dups) + 2);
              }
              goto __pyx_L16;
            }

     331:                 elif tiebreak == TIEBREAK_MAX:

            /* "pandas/algos.pyx":331
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1
     */
            __pyx_t_27 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MAX) != 0);
            if (__pyx_t_27) {

     332:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":332
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     */
              __pyx_t_28 = (__pyx_v_j + 1);
              for (__pyx_t_29 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
                __pyx_v_z = __pyx_t_29;

     333:                         ranks[i, argsorted[i, z]] = j + 1

                /* "pandas/algos.pyx":333
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_38 = __pyx_v_i;
                __pyx_t_39 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_38 < 0) {
                  __pyx_t_38 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_38 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_38 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_39 < 0) {
                  __pyx_t_39 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_39 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_40 = __pyx_v_i;
                __pyx_t_41 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_40 < 0) {
                  __pyx_t_40 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_40 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_40 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_41 < 0) {
                  __pyx_t_41 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_41 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_41 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_j + 1);
              }
              goto __pyx_L16;
            }

     334:                 elif tiebreak == TIEBREAK_FIRST:

            /* "pandas/algos.pyx":334
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = z + 1
     */
            __pyx_t_27 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
            if (__pyx_t_27) {

     335:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":335
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = z + 1
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     */
              __pyx_t_28 = (__pyx_v_j + 1);
              for (__pyx_t_29 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
                __pyx_v_z = __pyx_t_29;

     336:                         ranks[i, argsorted[i, z]] = z + 1

                /* "pandas/algos.pyx":336
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = z + 1             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_42 = __pyx_v_i;
                __pyx_t_43 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_42 < 0) {
                  __pyx_t_42 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_42 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_42 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_43 < 0) {
                  __pyx_t_43 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_43 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_43 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_44 = __pyx_v_i;
                __pyx_t_45 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_44 < 0) {
                  __pyx_t_44 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_44 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_44 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_45 < 0) {
                  __pyx_t_45 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_45 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_45 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_z + 1);
              }
              goto __pyx_L16;
            }

     337:                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:

            /* "pandas/algos.pyx":337
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = z + 1
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2
     */
            __pyx_t_27 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING) != 0);
            if (__pyx_t_27) {

     338:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":338
     *                         ranks[i, argsorted[i, z]] = z + 1
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2
     *                 sum_ranks = dups = 0
     */
              __pyx_t_28 = (__pyx_v_j + 1);
              for (__pyx_t_29 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
                __pyx_v_z = __pyx_t_29;

     339:                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2

                /* "pandas/algos.pyx":339
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2             # <<<<<<<<<<<<<<
     *                 sum_ranks = dups = 0
     *
     */
                __pyx_t_46 = __pyx_v_i;
                __pyx_t_47 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_46 < 0) {
                  __pyx_t_46 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_46 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_46 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_47 < 0) {
                  __pyx_t_47 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_47 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_47 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_48 = __pyx_v_i;
                __pyx_t_49 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_47, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_48 < 0) {
                  __pyx_t_48 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_48 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_48 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_49 < 0) {
                  __pyx_t_49 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_49 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_49 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_49, __pyx_pybuffernd_ranks.diminfo[1].strides) = ((((2 * __pyx_v_j) - __pyx_v_z) - __pyx_v_dups) + 2);
              }
              goto __pyx_L16;
            }
            __pyx_L16:;

     340:                 sum_ranks = dups = 0

            /* "pandas/algos.pyx":340
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2
     *                 sum_ranks = dups = 0             # <<<<<<<<<<<<<<
     *
     *     if axis == 0:
     */
            __pyx_v_sum_ranks = 0;
            __pyx_v_dups = 0;
            goto __pyx_L15;
          }
          __pyx_L15:;
          __pyx_L12_continue:;
        }
      }

     341:

     342:     if axis == 0:

      /* "pandas/algos.pyx":342
     *                 sum_ranks = dups = 0
     *
     *     if axis == 0:             # <<<<<<<<<<<<<<
     *         return ranks.T
     *     else:
     */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_27 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_27) {

     343:         return ranks.T

        /* "pandas/algos.pyx":343
     *
     *     if axis == 0:
     *         return ranks.T             # <<<<<<<<<<<<<<
     *     else:
     *         return ranks
     */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ranks), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      /*else*/ {

     344:     else:

     345:         return ranks

        /* "pandas/algos.pyx":345
     *         return ranks.T
     *     else:
     *         return ranks             # <<<<<<<<<<<<<<
     *
     *
     */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
        __pyx_r = ((PyObject *)__pyx_v_ranks);
        goto __pyx_L0;
      }

     346:

     347:

     348: def rank_2d_int64(object in_arr, axis=0, ties_method='average',

    /* "pandas/algos.pyx":348
     *
     *
     * def rank_2d_int64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_7rank_2d_int64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_6rank_2d_int64[] = "\n    Fast NaN-friendly version of scipy.stats.rankdata\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_7rank_2d_int64 = {__Pyx_NAMESTR("rank_2d_int64"), (PyCFunction)__pyx_pw_6pandas_5algos_7rank_2d_int64, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_6rank_2d_int64)};
    static PyObject *__pyx_pw_6pandas_5algos_7rank_2d_int64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_in_arr = 0;
      PyObject *__pyx_v_axis = 0;
      PyObject *__pyx_v_ties_method = 0;
      PyObject *__pyx_v_ascending = 0;
      CYTHON_UNUSED PyObject *__pyx_v_na_option = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_2d_int64 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_arr,&__pyx_n_s_axis,&__pyx_n_s_ties_method,&__pyx_n_s_ascending,&__pyx_n_s_na_option,0};
        PyObject* values[5] = {0,0,0,0,0};
        values[1] = ((PyObject *)__pyx_int_0);
        values[2] = ((PyObject *)__pyx_n_s_average);

      /* "pandas/algos.pyx":348
     *
     *
     * def rank_2d_int64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_6rank_2d_int64(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_arr, PyObject *__pyx_v_axis, PyObject *__pyx_v_ties_method, PyObject *__pyx_v_ascending, CYTHON_UNUSED PyObject *__pyx_v_na_option) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_z;
      Py_ssize_t __pyx_v_k;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_dups;
      PyArrayObject *__pyx_v_ranks = 0;
      PyArrayObject *__pyx_v_argsorted = 0;
      PyArrayObject *__pyx_v_values = 0;
      __pyx_t_5numpy_int64_t __pyx_v_val;
      __pyx_t_5numpy_float64_t __pyx_v_sum_ranks;
      int __pyx_v_tiebreak;
      PyObject *__pyx_v__as = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_argsorted;
      __Pyx_Buffer __pyx_pybuffer_argsorted;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_ranks;
      __Pyx_Buffer __pyx_pybuffer_ranks;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_2d_int64", 0);
      __pyx_pybuffer_ranks.pybuffer.buf = NULL;
      __pyx_pybuffer_ranks.refcount = 0;
      __pyx_pybuffernd_ranks.data = NULL;
      __pyx_pybuffernd_ranks.rcbuffer = &__pyx_pybuffer_ranks;
      __pyx_pybuffer_argsorted.pybuffer.buf = NULL;
      __pyx_pybuffer_argsorted.refcount = 0;
      __pyx_pybuffernd_argsorted.data = NULL;
      __pyx_pybuffernd_argsorted.rcbuffer = &__pyx_pybuffer_argsorted;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;

      /* "pandas/algos.pyx":348
     *
     *
     * def rank_2d_int64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_10);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.rank_2d_int64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_ranks);
      __Pyx_XDECREF((PyObject *)__pyx_v_argsorted);
      __Pyx_XDECREF((PyObject *)__pyx_v_values);
      __Pyx_XDECREF(__pyx_v__as);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":348
     *
     *
     * def rank_2d_int64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_tuple__222 = PyTuple_Pack(18, __pyx_n_s_in_arr, __pyx_n_s_axis, __pyx_n_s_ties_method, __pyx_n_s_ascending, __pyx_n_s_na_option, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_z, __pyx_n_s_k, __pyx_n_s_n, __pyx_n_s_dups, __pyx_n_s_ranks, __pyx_n_s_argsorted, __pyx_n_s_values, __pyx_n_s_val, __pyx_n_s_sum_ranks, __pyx_n_s_tiebreak, __pyx_n_s_as); if (unlikely(!__pyx_tuple__222)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__222);
      __Pyx_GIVEREF(__pyx_tuple__222);

      /* "pandas/algos.pyx":348
     *
     *
     * def rank_2d_int64(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_7rank_2d_int64, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rank_2d_int64, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__223 = (PyObject*)__Pyx_PyCode_New(5, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__222, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_rank_2d_int64, 348, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__223)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     349:                     ascending=True, na_option='keep'):

        /* "pandas/algos.pyx":349
     *
     * def rank_2d_int64(object in_arr, axis=0, ties_method='average',
     *                     ascending=True, na_option='keep'):             # <<<<<<<<<<<<<<
     *     """
     *     Fast NaN-friendly version of scipy.stats.rankdata
     */
        values[3] = ((PyObject *)Py_True);
        values[4] = ((PyObject *)__pyx_n_s_keep);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arr)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ties_method);
              if (value) { values[2] = value; kw_args--; }
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ascending);
              if (value) { values[3] = value; kw_args--; }
            }
            case  4:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_na_option);
              if (value) { values[4] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rank_2d_int64") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_in_arr = values[0];
        __pyx_v_axis = values[1];
        __pyx_v_ties_method = values[2];
        __pyx_v_ascending = values[3];
        __pyx_v_na_option = values[4];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("rank_2d_int64", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.rank_2d_int64", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_6rank_2d_int64(__pyx_self, __pyx_v_in_arr, __pyx_v_axis, __pyx_v_ties_method, __pyx_v_ascending, __pyx_v_na_option);

     350:     """

     351:     Fast NaN-friendly version of scipy.stats.rankdata

     352:     """

     353:

     354:     cdef:

     355:         Py_ssize_t i, j, z, k, n, dups = 0

      /* "pandas/algos.pyx":355
     *
     *     cdef:
     *         Py_ssize_t i, j, z, k, n, dups = 0             # <<<<<<<<<<<<<<
     *         ndarray[float64_t, ndim=2] ranks
     *         ndarray[int64_t, ndim=2] argsorted
     */
      __pyx_v_dups = 0;

     356:         ndarray[float64_t, ndim=2] ranks

     357:         ndarray[int64_t, ndim=2] argsorted

     358:         ndarray[int64_t, ndim=2, cast=True] values

     359:         int64_t val

     360:         float64_t sum_ranks = 0

      /* "pandas/algos.pyx":360
     *         ndarray[int64_t, ndim=2, cast=True] values
     *         int64_t val
     *         float64_t sum_ranks = 0             # <<<<<<<<<<<<<<
     *         int tiebreak = 0
     *     tiebreak = tiebreakers[ties_method]
     */
      __pyx_v_sum_ranks = 0.0;

     361:         int tiebreak = 0

      /* "pandas/algos.pyx":361
     *         int64_t val
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0             # <<<<<<<<<<<<<<
     *     tiebreak = tiebreakers[ties_method]
     *
     */
      __pyx_v_tiebreak = 0;

     362:     tiebreak = tiebreakers[ties_method]

      /* "pandas/algos.pyx":362
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0
     *     tiebreak = tiebreakers[ties_method]             # <<<<<<<<<<<<<<
     *
     *     if axis == 0:
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tiebreakers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_ties_method); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tiebreak = __pyx_t_3;

     363:

     364:     if axis == 0:

      /* "pandas/algos.pyx":364
     *     tiebreak = tiebreakers[ties_method]
     *
     *     if axis == 0:             # <<<<<<<<<<<<<<
     *         values = np.asarray(in_arr).T
     *     else:
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_4) {

     365:         values = np.asarray(in_arr).T

        /* "pandas/algos.pyx":365
     *
     *     if axis == 0:
     *         values = np.asarray(in_arr).T             # <<<<<<<<<<<<<<
     *     else:
     *         values = np.asarray(in_arr)
     */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_in_arr);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
        __Pyx_GIVEREF(__pyx_v_in_arr);
        __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_T); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_values = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L3;
      }
      /*else*/ {

     366:     else:

     367:         values = np.asarray(in_arr)

        /* "pandas/algos.pyx":367
     *         values = np.asarray(in_arr).T
     *     else:
     *         values = np.asarray(in_arr)             # <<<<<<<<<<<<<<
     *
     *     n, k = (<object> values).shape
     */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_in_arr);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
        __Pyx_GIVEREF(__pyx_v_in_arr);
        __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_values = ((PyArrayObject *)__pyx_t_1);
        __pyx_t_1 = 0;
      }
      __pyx_L3:;

     368:

     369:     n, k = (<object> values).shape

      /* "pandas/algos.pyx":369
     *         values = np.asarray(in_arr)
     *
     *     n, k = (<object> values).shape             # <<<<<<<<<<<<<<
     *     ranks = np.empty((n, k), dtype='f8')
     *
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L5_unpacking_done;
        __pyx_L4_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L5_unpacking_done:;
      }
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_n = __pyx_t_12;
      __pyx_v_k = __pyx_t_13;

     370:     ranks = np.empty((n, k), dtype='f8')

      /* "pandas/algos.pyx":370
     *
     *     n, k = (<object> values).shape
     *     ranks = np.empty((n, k), dtype='f8')             # <<<<<<<<<<<<<<
     *
     *     if tiebreak == TIEBREAK_FIRST:
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, __pyx_n_s_f8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_v_ranks, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          }
        }
        __pyx_pybuffernd_ranks.diminfo[0].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ranks.diminfo[0].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ranks.diminfo[1].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ranks.diminfo[1].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_ranks = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     371:

     372:     if tiebreak == TIEBREAK_FIRST:

      /* "pandas/algos.pyx":372
     *     ranks = np.empty((n, k), dtype='f8')
     *
     *     if tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *         # need to use a stable sort here
     *         _as = values.argsort(axis=1, kind='mergesort')
     */
      __pyx_t_4 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
      if (__pyx_t_4) {

     373:         # need to use a stable sort here

     374:         _as = values.argsort(axis=1, kind='mergesort')

        /* "pandas/algos.pyx":374
     *     if tiebreak == TIEBREAK_FIRST:
     *         # need to use a stable sort here
     *         _as = values.argsort(axis=1, kind='mergesort')             # <<<<<<<<<<<<<<
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_axis, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_kind, __pyx_n_s_mergesort) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_v__as = __pyx_t_2;
        __pyx_t_2 = 0;

     375:         if not ascending:

        /* "pandas/algos.pyx":375
     *         # need to use a stable sort here
     *         _as = values.argsort(axis=1, kind='mergesort')
     *         if not ascending:             # <<<<<<<<<<<<<<
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     */
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_15 = ((!__pyx_t_4) != 0);
        if (__pyx_t_15) {

     376:             tiebreak = TIEBREAK_FIRST_DESCENDING

          /* "pandas/algos.pyx":376
     *         _as = values.argsort(axis=1, kind='mergesort')
     *         if not ascending:
     *             tiebreak = TIEBREAK_FIRST_DESCENDING             # <<<<<<<<<<<<<<
     *     else:
     *         _as = values.argsort(1)
     */
          __pyx_v_tiebreak = __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING;
          goto __pyx_L7;
        }
        __pyx_L7:;
        goto __pyx_L6;
      }
      /*else*/ {

     377:     else:

     378:         _as = values.argsort(1)

        /* "pandas/algos.pyx":378
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     *         _as = values.argsort(1)             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v__as = __pyx_t_10;
        __pyx_t_10 = 0;
      }
      __pyx_L6:;

      /* "pandas/algos.pyx":378
     *             tiebreak = TIEBREAK_FIRST_DESCENDING
     *     else:
     *         _as = values.argsort(1)             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
      __pyx_tuple__11 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__11);
      __Pyx_GIVEREF(__pyx_tuple__11);

     379:

     380:     if not ascending:

      /* "pandas/algos.pyx":380
     *         _as = values.argsort(1)
     *
     *     if not ascending:             # <<<<<<<<<<<<<<
     *         _as = _as[:, ::-1]
     *
     */
      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = ((!__pyx_t_15) != 0);
      if (__pyx_t_4) {

     381:         _as = _as[:, ::-1]

      /* "pandas/algos.pyx":381
     *
     *     if not ascending:
     *         _as = _as[:, ::-1]             # <<<<<<<<<<<<<<
     *
     *     values = _take_2d_int64(values, _as)
     */
      __pyx_slice__12 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__12);
      __Pyx_GIVEREF(__pyx_slice__12);
      __pyx_slice__13 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__13);
      __Pyx_GIVEREF(__pyx_slice__13);

        /* "pandas/algos.pyx":381
     *
     *     if not ascending:
     *         _as = _as[:, ::-1]             # <<<<<<<<<<<<<<
     *
     *     values = _take_2d_int64(values, _as)
     */
        __pyx_t_10 = PyObject_GetItem(__pyx_v__as, __pyx_tuple__14); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF_SET(__pyx_v__as, __pyx_t_10);
        __pyx_t_10 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
      __pyx_tuple__14 = PyTuple_Pack(2, __pyx_slice__12, __pyx_slice__13); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__14);
      __Pyx_GIVEREF(__pyx_tuple__14);

     382:

     383:     values = _take_2d_int64(values, _as)

      /* "pandas/algos.pyx":383
     *         _as = _as[:, ::-1]
     *
     *     values = _take_2d_int64(values, _as)             # <<<<<<<<<<<<<<
     *     argsorted = _as.astype('i8')
     *
     */
      __pyx_t_10 = __pyx_f_6pandas_5algos__take_2d_int64(((PyArrayObject *)__pyx_v_values), __pyx_v__as); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 1, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
          }
        }
        __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_values, ((PyArrayObject *)__pyx_t_10));
      __pyx_t_10 = 0;

     384:     argsorted = _as.astype('i8')

      /* "pandas/algos.pyx":384
     *
     *     values = _take_2d_int64(values, _as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v__as, __pyx_n_s_astype); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_2 = PyObject_Call(__pyx_t_10, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          }
        }
        __pyx_pybuffernd_argsorted.diminfo[0].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_argsorted.diminfo[0].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_argsorted.diminfo[1].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_argsorted.diminfo[1].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_16 = 0;
      __pyx_v_argsorted = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pandas/algos.pyx":384
     *
     *     values = _take_2d_int64(values, _as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_tuple__15 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__15);
      __Pyx_GIVEREF(__pyx_tuple__15);

     385:

     386:     for i in range(n):

      /* "pandas/algos.pyx":386
     *     argsorted = _as.astype('i8')
     *
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         dups = sum_ranks = 0
     *         for j in range(k):
     */
      __pyx_t_13 = __pyx_v_n;
      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_13; __pyx_t_12+=1) {
        __pyx_v_i = __pyx_t_12;

     387:         dups = sum_ranks = 0

        /* "pandas/algos.pyx":387
     *
     *     for i in range(n):
     *         dups = sum_ranks = 0             # <<<<<<<<<<<<<<
     *         for j in range(k):
     *             sum_ranks += j + 1
     */
        __pyx_v_dups = 0;
        __pyx_v_sum_ranks = 0;

     388:         for j in range(k):

        /* "pandas/algos.pyx":388
     *     for i in range(n):
     *         dups = sum_ranks = 0
     *         for j in range(k):             # <<<<<<<<<<<<<<
     *             sum_ranks += j + 1
     *             dups += 1
     */
        __pyx_t_17 = __pyx_v_k;
        for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
          __pyx_v_j = __pyx_t_18;

     389:             sum_ranks += j + 1

          /* "pandas/algos.pyx":389
     *         dups = sum_ranks = 0
     *         for j in range(k):
     *             sum_ranks += j + 1             # <<<<<<<<<<<<<<
     *             dups += 1
     *             val = values[i, j]
     */
          __pyx_v_sum_ranks = (__pyx_v_sum_ranks + (__pyx_v_j + 1));

     390:             dups += 1

          /* "pandas/algos.pyx":390
     *         for j in range(k):
     *             sum_ranks += j + 1
     *             dups += 1             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     */
          __pyx_v_dups = (__pyx_v_dups + 1);

     391:             val = values[i, j]

          /* "pandas/algos.pyx":391
     *             sum_ranks += j + 1
     *             dups += 1
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     *                 if tiebreak == TIEBREAK_AVERAGE:
     */
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_20 = __pyx_v_j;
          __pyx_t_3 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_values.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_3 = 0;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_values.diminfo[1].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_3 = 1;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_3 = 1;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_val = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_values.diminfo[1].strides));

     392:             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:

          /* "pandas/algos.pyx":392
     *             dups += 1
     *             val = values[i, j]
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:             # <<<<<<<<<<<<<<
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):
     */
          __pyx_t_4 = ((__pyx_v_j == (__pyx_v_k - 1)) != 0);
          if (!__pyx_t_4) {
            __pyx_t_21 = __pyx_v_i;
            __pyx_t_22 = (__pyx_v_j + 1);
            __pyx_t_3 = -1;
            if (__pyx_t_21 < 0) {
              __pyx_t_21 += __pyx_pybuffernd_values.diminfo[0].shape;
              if (unlikely(__pyx_t_21 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_22 < 0) {
              __pyx_t_22 += __pyx_pybuffernd_values.diminfo[1].shape;
              if (unlikely(__pyx_t_22 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_15 = ((fabs(((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_values.diminfo[1].strides)) - __pyx_v_val)) > __pyx_v_6pandas_5algos_FP_ERR) != 0);
            __pyx_t_23 = __pyx_t_15;
          } else {
            __pyx_t_23 = __pyx_t_4;
          }
          if (__pyx_t_23) {

     393:                 if tiebreak == TIEBREAK_AVERAGE:

            /* "pandas/algos.pyx":393
     *             val = values[i, j]
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     *                 if tiebreak == TIEBREAK_AVERAGE:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     */
            __pyx_t_23 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE) != 0);
            if (__pyx_t_23) {

     394:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":394
     *             if j == k - 1 or fabs(values[i, j + 1] - val) > FP_ERR:
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:
     */
              __pyx_t_24 = (__pyx_v_j + 1);
              for (__pyx_t_25 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) {
                __pyx_v_z = __pyx_t_25;

     395:                         ranks[i, argsorted[i, z]] = sum_ranks / dups

                /* "pandas/algos.pyx":395
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):
     */
                if (unlikely(__pyx_v_dups == 0)) {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                  #endif
                  PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                  #ifdef WITH_THREAD
                  PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_26 = __pyx_v_i;
                __pyx_t_27 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_26 < 0) {
                  __pyx_t_26 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_26 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_27 < 0) {
                  __pyx_t_27 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_27 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_28 = __pyx_v_i;
                __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_28 < 0) {
                  __pyx_t_28 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_28 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_29 < 0) {
                  __pyx_t_29 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_29 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_sum_ranks / __pyx_v_dups);
              }
              goto __pyx_L14;
            }

     396:                 elif tiebreak == TIEBREAK_MIN:

            /* "pandas/algos.pyx":396
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     */
            __pyx_t_23 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MIN) != 0);
            if (__pyx_t_23) {

     397:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":397
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:
     */
              __pyx_t_24 = (__pyx_v_j + 1);
              for (__pyx_t_25 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) {
                __pyx_v_z = __pyx_t_25;

     398:                         ranks[i, argsorted[i, z]] = j - dups + 2

                /* "pandas/algos.pyx":398
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_30 = __pyx_v_i;
                __pyx_t_31 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_30 < 0) {
                  __pyx_t_30 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_30 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_31 < 0) {
                  __pyx_t_31 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_31 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_32 = __pyx_v_i;
                __pyx_t_33 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_32 < 0) {
                  __pyx_t_32 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_32 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_33 < 0) {
                  __pyx_t_33 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_33 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_ranks.diminfo[1].strides) = ((__pyx_v_j - __pyx_v_dups) + 2);
              }
              goto __pyx_L14;
            }

     399:                 elif tiebreak == TIEBREAK_MAX:

            /* "pandas/algos.pyx":399
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1
     */
            __pyx_t_23 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MAX) != 0);
            if (__pyx_t_23) {

     400:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":400
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     */
              __pyx_t_24 = (__pyx_v_j + 1);
              for (__pyx_t_25 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) {
                __pyx_v_z = __pyx_t_25;

     401:                         ranks[i, argsorted[i, z]] = j + 1

                /* "pandas/algos.pyx":401
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_34 = __pyx_v_i;
                __pyx_t_35 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_34 < 0) {
                  __pyx_t_34 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_34 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_34 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_35 < 0) {
                  __pyx_t_35 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_35 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_36 = __pyx_v_i;
                __pyx_t_37 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_36 < 0) {
                  __pyx_t_36 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_36 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_36 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_37 < 0) {
                  __pyx_t_37 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_37 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_j + 1);
              }
              goto __pyx_L14;
            }

     402:                 elif tiebreak == TIEBREAK_FIRST:

            /* "pandas/algos.pyx":402
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = z + 1
     */
            __pyx_t_23 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
            if (__pyx_t_23) {

     403:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":403
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = z + 1
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     */
              __pyx_t_24 = (__pyx_v_j + 1);
              for (__pyx_t_25 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) {
                __pyx_v_z = __pyx_t_25;

     404:                         ranks[i, argsorted[i, z]] = z + 1

                /* "pandas/algos.pyx":404
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = z + 1             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_38 = __pyx_v_i;
                __pyx_t_39 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_38 < 0) {
                  __pyx_t_38 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_38 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_38 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_39 < 0) {
                  __pyx_t_39 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_39 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_40 = __pyx_v_i;
                __pyx_t_41 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_40 < 0) {
                  __pyx_t_40 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_40 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_40 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_41 < 0) {
                  __pyx_t_41 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_41 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_41 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_z + 1);
              }
              goto __pyx_L14;
            }

     405:                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:

            /* "pandas/algos.pyx":405
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = z + 1
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2
     */
            __pyx_t_23 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST_DESCENDING) != 0);
            if (__pyx_t_23) {

     406:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":406
     *                         ranks[i, argsorted[i, z]] = z + 1
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2
     *                 sum_ranks = dups = 0
     */
              __pyx_t_24 = (__pyx_v_j + 1);
              for (__pyx_t_25 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) {
                __pyx_v_z = __pyx_t_25;

     407:                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2

                /* "pandas/algos.pyx":407
     *                 elif tiebreak == TIEBREAK_FIRST_DESCENDING:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2             # <<<<<<<<<<<<<<
     *                 sum_ranks = dups = 0
     *
     */
                __pyx_t_42 = __pyx_v_i;
                __pyx_t_43 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_42 < 0) {
                  __pyx_t_42 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_42 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_42 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_43 < 0) {
                  __pyx_t_43 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_43 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_43 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_44 = __pyx_v_i;
                __pyx_t_45 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_44 < 0) {
                  __pyx_t_44 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_44 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_44 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_45 < 0) {
                  __pyx_t_45 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_45 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_45 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_ranks.diminfo[1].strides) = ((((2 * __pyx_v_j) - __pyx_v_z) - __pyx_v_dups) + 2);
              }
              goto __pyx_L14;
            }
            __pyx_L14:;

     408:                 sum_ranks = dups = 0

            /* "pandas/algos.pyx":408
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = 2 * j - z - dups + 2
     *                 sum_ranks = dups = 0             # <<<<<<<<<<<<<<
     *
     *     if axis == 0:
     */
            __pyx_v_sum_ranks = 0;
            __pyx_v_dups = 0;
            goto __pyx_L13;
          }
          __pyx_L13:;
        }
      }

     409:

     410:     if axis == 0:

      /* "pandas/algos.pyx":410
     *                 sum_ranks = dups = 0
     *
     *     if axis == 0:             # <<<<<<<<<<<<<<
     *         return ranks.T
     *     else:
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_23 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_23) {

     411:         return ranks.T

        /* "pandas/algos.pyx":411
     *
     *     if axis == 0:
     *         return ranks.T             # <<<<<<<<<<<<<<
     *     else:
     *         return ranks
     */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ranks), __pyx_n_s_T); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L0;
      }
      /*else*/ {

     412:     else:

     413:         return ranks

        /* "pandas/algos.pyx":413
     *         return ranks.T
     *     else:
     *         return ranks             # <<<<<<<<<<<<<<
     *
     *
     */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
        __pyx_r = ((PyObject *)__pyx_v_ranks);
        goto __pyx_L0;
      }

     414:

     415:

     416: def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',

    /* "pandas/algos.pyx":416
     *
     *
     * def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_9rank_1d_generic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_8rank_1d_generic[] = "\n    Fast NaN-friendly version of scipy.stats.rankdata\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_9rank_1d_generic = {__Pyx_NAMESTR("rank_1d_generic"), (PyCFunction)__pyx_pw_6pandas_5algos_9rank_1d_generic, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_8rank_1d_generic)};
    static PyObject *__pyx_pw_6pandas_5algos_9rank_1d_generic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_in_arr = 0;
      int __pyx_v_retry;
      PyObject *__pyx_v_ties_method = 0;
      PyObject *__pyx_v_ascending = 0;
      PyObject *__pyx_v_na_option = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_1d_generic (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_arr,&__pyx_n_s_retry,&__pyx_n_s_ties_method,&__pyx_n_s_ascending,&__pyx_n_s_na_option,0};
        PyObject* values[5] = {0,0,0,0,0};
        values[2] = ((PyObject *)__pyx_n_s_average);

      /* "pandas/algos.pyx":416
     *
     *
     * def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_8rank_1d_generic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_arr, int __pyx_v_retry, PyObject *__pyx_v_ties_method, PyObject *__pyx_v_ascending, PyObject *__pyx_v_na_option) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_dups;
      PyArrayObject *__pyx_v_ranks = 0;
      PyArrayObject *__pyx_v_sorted_data = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_argsorted = 0;
      PyObject *__pyx_v_val = 0;
      PyObject *__pyx_v_nan_value = 0;
      __pyx_t_5numpy_float64_t __pyx_v_sum_ranks;
      int __pyx_v_tiebreak;
      int __pyx_v_keep_na;
      PyObject *__pyx_v_mask = NULL;
      PyObject *__pyx_v__as = NULL;
      PyObject *__pyx_v_valid_locs = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_argsorted;
      __Pyx_Buffer __pyx_pybuffer_argsorted;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_ranks;
      __Pyx_Buffer __pyx_pybuffer_ranks;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_1d_generic", 0);
      __pyx_pybuffer_ranks.pybuffer.buf = NULL;
      __pyx_pybuffer_ranks.refcount = 0;
      __pyx_pybuffernd_ranks.data = NULL;
      __pyx_pybuffernd_ranks.rcbuffer = &__pyx_pybuffer_ranks;
      __pyx_pybuffer_argsorted.pybuffer.buf = NULL;
      __pyx_pybuffer_argsorted.refcount = 0;
      __pyx_pybuffernd_argsorted.data = NULL;
      __pyx_pybuffernd_argsorted.rcbuffer = &__pyx_pybuffer_argsorted;

      /* "pandas/algos.pyx":416
     *
     *
     * def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_12);
      __Pyx_XDECREF(__pyx_t_13);
      __Pyx_XDECREF(__pyx_t_14);
      __Pyx_XDECREF(__pyx_t_15);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.rank_1d_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_ranks);
      __Pyx_XDECREF((PyObject *)__pyx_v_sorted_data);
      __Pyx_XDECREF((PyObject *)__pyx_v_values);
      __Pyx_XDECREF((PyObject *)__pyx_v_argsorted);
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XDECREF(__pyx_v_nan_value);
      __Pyx_XDECREF(__pyx_v_mask);
      __Pyx_XDECREF(__pyx_v__as);
      __Pyx_XDECREF(__pyx_v_valid_locs);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":416
     *
     *
     * def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_tuple__224 = PyTuple_Pack(21, __pyx_n_s_in_arr, __pyx_n_s_retry, __pyx_n_s_ties_method, __pyx_n_s_ascending, __pyx_n_s_na_option, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_n, __pyx_n_s_dups, __pyx_n_s_ranks, __pyx_n_s_sorted_data, __pyx_n_s_values, __pyx_n_s_argsorted, __pyx_n_s_val, __pyx_n_s_nan_value, __pyx_n_s_sum_ranks, __pyx_n_s_tiebreak, __pyx_n_s_keep_na, __pyx_n_s_mask, __pyx_n_s_as, __pyx_n_s_valid_locs); if (unlikely(!__pyx_tuple__224)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__224);
      __Pyx_GIVEREF(__pyx_tuple__224);

      /* "pandas/algos.pyx":416
     *
     *
     * def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_9rank_1d_generic, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rank_1d_generic, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__225 = (PyObject*)__Pyx_PyCode_New(5, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__224, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_rank_1d_generic, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__225)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     417:                     ascending=True, na_option='keep'):

        /* "pandas/algos.pyx":417
     *
     * def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',
     *                     ascending=True, na_option='keep'):             # <<<<<<<<<<<<<<
     *     """
     *     Fast NaN-friendly version of scipy.stats.rankdata
     */
        values[3] = ((PyObject *)Py_True);
        values[4] = ((PyObject *)__pyx_n_s_keep);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arr)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_retry);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ties_method);
              if (value) { values[2] = value; kw_args--; }
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ascending);
              if (value) { values[3] = value; kw_args--; }
            }
            case  4:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_na_option);
              if (value) { values[4] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rank_1d_generic") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_in_arr = values[0];
        if (values[1]) {
          __pyx_v_retry = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_retry == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        } else {
          __pyx_v_retry = ((int)1);
        }
        __pyx_v_ties_method = values[2];
        __pyx_v_ascending = values[3];
        __pyx_v_na_option = values[4];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("rank_1d_generic", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.rank_1d_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_8rank_1d_generic(__pyx_self, __pyx_v_in_arr, __pyx_v_retry, __pyx_v_ties_method, __pyx_v_ascending, __pyx_v_na_option);

     418:     """

     419:     Fast NaN-friendly version of scipy.stats.rankdata

     420:     """

     421:

     422:     cdef:

     423:         Py_ssize_t i, j, n, dups = 0

      /* "pandas/algos.pyx":423
     *
     *     cdef:
     *         Py_ssize_t i, j, n, dups = 0             # <<<<<<<<<<<<<<
     *         ndarray[float64_t] ranks
     *         ndarray sorted_data, values
     */
      __pyx_v_dups = 0;

     424:         ndarray[float64_t] ranks

     425:         ndarray sorted_data, values

     426:         ndarray[int64_t] argsorted

     427:         object val, nan_value

     428:         float64_t sum_ranks = 0

      /* "pandas/algos.pyx":428
     *         ndarray[int64_t] argsorted
     *         object val, nan_value
     *         float64_t sum_ranks = 0             # <<<<<<<<<<<<<<
     *         int tiebreak = 0
     *         bint keep_na = 0
     */
      __pyx_v_sum_ranks = 0.0;

     429:         int tiebreak = 0

      /* "pandas/algos.pyx":429
     *         object val, nan_value
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0             # <<<<<<<<<<<<<<
     *         bint keep_na = 0
     *
     */
      __pyx_v_tiebreak = 0;

     430:         bint keep_na = 0

      /* "pandas/algos.pyx":430
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0
     *         bint keep_na = 0             # <<<<<<<<<<<<<<
     *
     *     tiebreak = tiebreakers[ties_method]
     */
      __pyx_v_keep_na = 0;

     431:

     432:     tiebreak = tiebreakers[ties_method]

      /* "pandas/algos.pyx":432
     *         bint keep_na = 0
     *
     *     tiebreak = tiebreakers[ties_method]             # <<<<<<<<<<<<<<
     *
     *     keep_na = na_option == 'keep'
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tiebreakers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_ties_method); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tiebreak = __pyx_t_3;

     433:

     434:     keep_na = na_option == 'keep'

      /* "pandas/algos.pyx":434
     *     tiebreak = tiebreakers[ties_method]
     *
     *     keep_na = na_option == 'keep'             # <<<<<<<<<<<<<<
     *
     *     values = np.array(in_arr, copy=True)
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_keep, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_keep_na = __pyx_t_4;

     435:

     436:     values = np.array(in_arr, copy=True)

      /* "pandas/algos.pyx":436
     *     keep_na = na_option == 'keep'
     *
     *     values = np.array(in_arr, copy=True)             # <<<<<<<<<<<<<<
     *
     *     if values.dtype != np.object_:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_in_arr);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
      __Pyx_GIVEREF(__pyx_v_in_arr);
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_copy, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_values = ((PyArrayObject *)__pyx_t_6);
      __pyx_t_6 = 0;

     437:

     438:     if values.dtype != np.object_:

      /* "pandas/algos.pyx":438
     *     values = np.array(in_arr, copy=True)
     *
     *     if values.dtype != np.object_:             # <<<<<<<<<<<<<<
     *         values = values.astype('O')
     *
     */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_object_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_RichCompare(__pyx_t_6, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     439:         values = values.astype('O')

        /* "pandas/algos.pyx":439
     *
     *     if values.dtype != np.object_:
     *         values = values.astype('O')             # <<<<<<<<<<<<<<
     *
     *     if ascending ^ (na_option == 'top'):
     */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF_SET(__pyx_v_values, ((PyArrayObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        goto __pyx_L3;
      }
      __pyx_L3:;

      /* "pandas/algos.pyx":439
     *
     *     if values.dtype != np.object_:
     *         values = values.astype('O')             # <<<<<<<<<<<<<<
     *
     *     if ascending ^ (na_option == 'top'):
     */
      __pyx_tuple__16 = PyTuple_Pack(1, __pyx_n_s_O); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__16);
      __Pyx_GIVEREF(__pyx_tuple__16);

     440:

     441:     if ascending ^ (na_option == 'top'):

      /* "pandas/algos.pyx":441
     *         values = values.astype('O')
     *
     *     if ascending ^ (na_option == 'top'):             # <<<<<<<<<<<<<<
     *         # always greater than everything
     *         nan_value = Infinity()
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_top, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyNumber_Xor(__pyx_v_ascending, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     442:         # always greater than everything

     443:         nan_value = Infinity()

        /* "pandas/algos.pyx":443
     *     if ascending ^ (na_option == 'top'):
     *         # always greater than everything
     *         nan_value = Infinity()             # <<<<<<<<<<<<<<
     *     else:
     *         nan_value = NegInfinity()
     */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Infinity); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_v_nan_value = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L4;
      }
      /*else*/ {

     444:     else:

     445:         nan_value = NegInfinity()

        /* "pandas/algos.pyx":445
     *         nan_value = Infinity()
     *     else:
     *         nan_value = NegInfinity()             # <<<<<<<<<<<<<<
     *
     *     mask = lib.isnullobj(values)
     */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NegInfinity); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_nan_value = __pyx_t_5;
        __pyx_t_5 = 0;
      }
      __pyx_L4:;

     446:

     447:     mask = lib.isnullobj(values)

      /* "pandas/algos.pyx":447
     *         nan_value = NegInfinity()
     *
     *     mask = lib.isnullobj(values)             # <<<<<<<<<<<<<<
     *     np.putmask(values, mask, nan_value)
     *
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isnullobj); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_6 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_mask = __pyx_t_6;
      __pyx_t_6 = 0;

     448:     np.putmask(values, mask, nan_value)

      /* "pandas/algos.pyx":448
     *
     *     mask = lib.isnullobj(values)
     *     np.putmask(values, mask, nan_value)             # <<<<<<<<<<<<<<
     *
     *     n = len(values)
     */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_putmask); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __Pyx_INCREF(__pyx_v_mask);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_mask);
      __Pyx_GIVEREF(__pyx_v_mask);
      __Pyx_INCREF(__pyx_v_nan_value);
      PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_nan_value);
      __Pyx_GIVEREF(__pyx_v_nan_value);
      __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     449:

     450:     n = len(values)

      /* "pandas/algos.pyx":450
     *     np.putmask(values, mask, nan_value)
     *
     *     n = len(values)             # <<<<<<<<<<<<<<
     *     ranks = np.empty(n, dtype='f8')
     *
     */
      __pyx_t_7 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_7;

     451:     ranks = np.empty(n, dtype='f8')

      /* "pandas/algos.pyx":451
     *
     *     n = len(values)
     *     ranks = np.empty(n, dtype='f8')             # <<<<<<<<<<<<<<
     *
     *     # py2.5/win32 hack, can't pass i8
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_n_s_f8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_v_ranks, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          }
        }
        __pyx_pybuffernd_ranks.diminfo[0].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ranks.diminfo[0].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_ranks = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     452:

     453:     # py2.5/win32 hack, can't pass i8

     454:     try:

      /* "pandas/algos.pyx":454
     *
     *     # py2.5/win32 hack, can't pass i8
     *     try:             # <<<<<<<<<<<<<<
     *         _as = values.argsort()
     *     except TypeError:
     */
      {
        /*try:*/ {

     455:         _as = values.argsort()

          /* "pandas/algos.pyx":455
     *     # py2.5/win32 hack, can't pass i8
     *     try:
     *         _as = values.argsort()             # <<<<<<<<<<<<<<
     *     except TypeError:
     *         if not retry:
     */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v__as = __pyx_t_2;
          __pyx_t_2 = 0;
        }
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_try_end;
        __pyx_L5_error:;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

     456:     except TypeError:

        /* "pandas/algos.pyx":456
     *     try:
     *         _as = values.argsort()
     *     except TypeError:             # <<<<<<<<<<<<<<
     *         if not retry:
     *             raise
     */
        __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
        if (__pyx_t_3) {
          __Pyx_AddTraceback("pandas.algos.rank_1d_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);

     457:         if not retry:

          /* "pandas/algos.pyx":457
     *         _as = values.argsort()
     *     except TypeError:
     *         if not retry:             # <<<<<<<<<<<<<<
     *             raise
     *
     */
          __pyx_t_4 = ((!(__pyx_v_retry != 0)) != 0);
          if (__pyx_t_4) {

     458:             raise

            /* "pandas/algos.pyx":458
     *     except TypeError:
     *         if not retry:
     *             raise             # <<<<<<<<<<<<<<
     *
     *         valid_locs = (-mask).nonzero()[0]
     */
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_XGIVEREF(__pyx_t_5);
            __Pyx_ErrRestore(__pyx_t_2, __pyx_t_1, __pyx_t_5);
            __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_5 = 0;
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          }

     459:

     460:         valid_locs = (-mask).nonzero()[0]

          /* "pandas/algos.pyx":460
     *             raise
     *
     *         valid_locs = (-mask).nonzero()[0]             # <<<<<<<<<<<<<<
     *         ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,
     *                                               ties_method=ties_method,
     */
          __pyx_t_6 = PyNumber_Negative(__pyx_v_mask); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = PyObject_Call(__pyx_t_12, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;};
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_v_valid_locs = __pyx_t_12;
          __pyx_t_12 = 0;

     461:         ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,

          /* "pandas/algos.pyx":461
     *
     *         valid_locs = (-mask).nonzero()[0]
     *         ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,             # <<<<<<<<<<<<<<
     *                                               ties_method=ties_method,
     *                                               ascending=ascending))
     */
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ranks), __pyx_n_s_put); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_rank_1d_generic); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_take); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_v_valid_locs);
          PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_valid_locs);
          __Pyx_GIVEREF(__pyx_v_valid_locs);
          __pyx_t_15 = PyObject_Call(__pyx_t_13, __pyx_t_14, NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_15);
          __Pyx_INCREF(__pyx_int_0);
          PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          __pyx_t_15 = 0;
          __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_15);

          /* "pandas/algos.pyx":461
     *
     *         valid_locs = (-mask).nonzero()[0]
     *         ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,             # <<<<<<<<<<<<<<
     *                                               ties_method=ties_method,
     *                                               ascending=ascending))
     */
          __pyx_t_13 = PyObject_Call(__pyx_t_6, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_INCREF(__pyx_v_valid_locs);
          PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_valid_locs);
          __Pyx_GIVEREF(__pyx_v_valid_locs);
          PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;
          __pyx_t_13 = PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

     462:                                               ties_method=ties_method,

          /* "pandas/algos.pyx":462
     *         valid_locs = (-mask).nonzero()[0]
     *         ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,
     *                                               ties_method=ties_method,             # <<<<<<<<<<<<<<
     *                                               ascending=ascending))
     *         np.putmask(ranks, mask, np.nan)
     */
          if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_ties_method, __pyx_v_ties_method) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

     463:                                               ascending=ascending))

          /* "pandas/algos.pyx":463
     *         ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,
     *                                               ties_method=ties_method,
     *                                               ascending=ascending))             # <<<<<<<<<<<<<<
     *         np.putmask(ranks, mask, np.nan)
     *         return ranks
     */
          if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_ascending, __pyx_v_ascending) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

     464:         np.putmask(ranks, mask, np.nan)

          /* "pandas/algos.pyx":464
     *                                               ties_method=ties_method,
     *                                               ascending=ascending))
     *         np.putmask(ranks, mask, np.nan)             # <<<<<<<<<<<<<<
     *         return ranks
     *
     */
          __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_putmask); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_nan); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
          PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_v_ranks));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_ranks));
          __Pyx_INCREF(__pyx_v_mask);
          PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_mask);
          __Pyx_GIVEREF(__pyx_v_mask);
          PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_12);
          __pyx_t_12 = 0;
          __pyx_t_12 = PyObject_Call(__pyx_t_15, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

     465:         return ranks

          /* "pandas/algos.pyx":465
     *                                               ascending=ascending))
     *         np.putmask(ranks, mask, np.nan)
     *         return ranks             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
          __Pyx_XDECREF(__pyx_r);
          __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
          __pyx_r = ((PyObject *)__pyx_v_ranks);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L8_except_return;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L6_exception_handled;
        }
        goto __pyx_L7_except_error;
        __pyx_L7_except_error:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
        goto __pyx_L1_error;
        __pyx_L8_except_return:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
        goto __pyx_L0;
        __pyx_L6_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
        __pyx_L12_try_end:;
      }

     466:

     467:     if not ascending:

      /* "pandas/algos.pyx":467
     *         return ranks
     *
     *     if not ascending:             # <<<<<<<<<<<<<<
     *         _as = _as[::-1]
     *
     */
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_16 = ((!__pyx_t_4) != 0);
      if (__pyx_t_16) {

     468:         _as = _as[::-1]

        /* "pandas/algos.pyx":468
     *
     *     if not ascending:
     *         _as = _as[::-1]             # <<<<<<<<<<<<<<
     *
     *     sorted_data = values.take(_as)
     */
        __pyx_t_5 = PyObject_GetItem(__pyx_v__as, __pyx_slice__17); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF_SET(__pyx_v__as, __pyx_t_5);
        __pyx_t_5 = 0;
        goto __pyx_L16;
      }
      __pyx_L16:;

      /* "pandas/algos.pyx":468
     *
     *     if not ascending:
     *         _as = _as[::-1]             # <<<<<<<<<<<<<<
     *
     *     sorted_data = values.take(_as)
     */
      __pyx_slice__17 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__17);
      __Pyx_GIVEREF(__pyx_slice__17);

     469:

     470:     sorted_data = values.take(_as)

      /* "pandas/algos.pyx":470
     *         _as = _as[::-1]
     *
     *     sorted_data = values.take(_as)             # <<<<<<<<<<<<<<
     *     argsorted = _as.astype('i8')
     *
     */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_take); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v__as);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__as);
      __Pyx_GIVEREF(__pyx_v__as);
      __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_sorted_data = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     471:     argsorted = _as.astype('i8')

      /* "pandas/algos.pyx":471
     *
     *     sorted_data = values.take(_as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v__as, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_17 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          }
        }
        __pyx_pybuffernd_argsorted.diminfo[0].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_argsorted.diminfo[0].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_17 = 0;
      __pyx_v_argsorted = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "pandas/algos.pyx":471
     *
     *     sorted_data = values.take(_as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_tuple__18 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__18);
      __Pyx_GIVEREF(__pyx_tuple__18);

     472:

     473:     for i in range(n):

      /* "pandas/algos.pyx":473
     *     argsorted = _as.astype('i8')
     *
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         sum_ranks += i + 1
     *         dups += 1
     */
      __pyx_t_7 = __pyx_v_n;
      for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_7; __pyx_t_18+=1) {
        __pyx_v_i = __pyx_t_18;

     474:         sum_ranks += i + 1

        /* "pandas/algos.pyx":474
     *
     *     for i in range(n):
     *         sum_ranks += i + 1             # <<<<<<<<<<<<<<
     *         dups += 1
     *         val = util.get_value_at(sorted_data, i)
     */
        __pyx_v_sum_ranks = (__pyx_v_sum_ranks + (__pyx_v_i + 1));

     475:         dups += 1

        /* "pandas/algos.pyx":475
     *     for i in range(n):
     *         sum_ranks += i + 1
     *         dups += 1             # <<<<<<<<<<<<<<
     *         val = util.get_value_at(sorted_data, i)
     *         if val is nan_value and keep_na:
     */
        __pyx_v_dups = (__pyx_v_dups + 1);

     476:         val = util.get_value_at(sorted_data, i)

        /* "pandas/algos.pyx":476
     *         sum_ranks += i + 1
     *         dups += 1
     *         val = util.get_value_at(sorted_data, i)             # <<<<<<<<<<<<<<
     *         if val is nan_value and keep_na:
     *             ranks[argsorted[i]] = nan
     */
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_f_4util_get_value_at(__pyx_v_sorted_data, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_2);
        __pyx_t_2 = 0;

     477:         if val is nan_value and keep_na:

        /* "pandas/algos.pyx":477
     *         dups += 1
     *         val = util.get_value_at(sorted_data, i)
     *         if val is nan_value and keep_na:             # <<<<<<<<<<<<<<
     *             ranks[argsorted[i]] = nan
     *             continue
     */
        __pyx_t_16 = (__pyx_v_val == __pyx_v_nan_value);
        if ((__pyx_t_16 != 0)) {
          __pyx_t_4 = (__pyx_v_keep_na != 0);
        } else {
          __pyx_t_4 = (__pyx_t_16 != 0);
        }
        if (__pyx_t_4) {

     478:             ranks[argsorted[i]] = nan

          /* "pandas/algos.pyx":478
     *         val = util.get_value_at(sorted_data, i)
     *         if val is nan_value and keep_na:
     *             ranks[argsorted[i]] = nan             # <<<<<<<<<<<<<<
     *             continue
     *         if (i == n - 1 or
     */
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_3 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_20 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_argsorted.diminfo[0].strides));
          __pyx_t_3 = -1;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_ranks.diminfo[0].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_ranks.diminfo[0].strides) = __pyx_v_6pandas_5algos_nan;

     479:             continue

          /* "pandas/algos.pyx":479
     *         if val is nan_value and keep_na:
     *             ranks[argsorted[i]] = nan
     *             continue             # <<<<<<<<<<<<<<
     *         if (i == n - 1 or
     *             are_diff(util.get_value_at(sorted_data, i + 1), val)):
     */
          goto __pyx_L17_continue;
        }

     480:         if (i == n - 1 or

        /* "pandas/algos.pyx":480
     *             ranks[argsorted[i]] = nan
     *             continue
     *         if (i == n - 1 or             # <<<<<<<<<<<<<<
     *             are_diff(util.get_value_at(sorted_data, i + 1), val)):
     *             if tiebreak == TIEBREAK_AVERAGE:
     */
        __pyx_t_4 = (__pyx_v_i == (__pyx_v_n - 1));
        if (!__pyx_t_4) {

     481:             are_diff(util.get_value_at(sorted_data, i + 1), val)):

          /* "pandas/algos.pyx":481
     *             continue
     *         if (i == n - 1 or
     *             are_diff(util.get_value_at(sorted_data, i + 1), val)):             # <<<<<<<<<<<<<<
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):
     */
          __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_i + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __pyx_f_4util_get_value_at(__pyx_v_sorted_data, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __pyx_f_6pandas_5algos_are_diff(__pyx_t_1, __pyx_v_val); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_21 = __pyx_t_16;
        } else {
          __pyx_t_21 = __pyx_t_4;
        }
        if (__pyx_t_21) {

     482:             if tiebreak == TIEBREAK_AVERAGE:

          /* "pandas/algos.pyx":482
     *         if (i == n - 1 or
     *             are_diff(util.get_value_at(sorted_data, i + 1), val)):
     *             if tiebreak == TIEBREAK_AVERAGE:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups
     */
          __pyx_t_21 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE) != 0);
          if (__pyx_t_21) {

     483:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":483
     *             are_diff(util.get_value_at(sorted_data, i + 1), val)):
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:
     */
            __pyx_t_22 = (__pyx_v_i + 1);
            for (__pyx_t_23 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) {
              __pyx_v_j = __pyx_t_23;

     484:                     ranks[argsorted[j]] = sum_ranks / dups

              /* "pandas/algos.pyx":484
     *             if tiebreak == TIEBREAK_AVERAGE:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):
     */
              if (unlikely(__pyx_v_dups == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_24 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_24 < 0) {
                __pyx_t_24 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_24 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_25 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_25 < 0) {
                __pyx_t_25 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_25 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_sum_ranks / __pyx_v_dups);
            }
            goto __pyx_L21;
          }

     485:             elif tiebreak == TIEBREAK_MIN:

          /* "pandas/algos.pyx":485
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2
     */
          __pyx_t_21 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MIN) != 0);
          if (__pyx_t_21) {

     486:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":486
     *                     ranks[argsorted[j]] = sum_ranks / dups
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:
     */
            __pyx_t_22 = (__pyx_v_i + 1);
            for (__pyx_t_23 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) {
              __pyx_v_j = __pyx_t_23;

     487:                     ranks[argsorted[j]] = i - dups + 2

              /* "pandas/algos.pyx":487
     *             elif tiebreak == TIEBREAK_MIN:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):
     */
              __pyx_t_26 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_26 < 0) {
                __pyx_t_26 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_26 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_27 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_27 < 0) {
                __pyx_t_27 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_27 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_ranks.diminfo[0].strides) = ((__pyx_v_i - __pyx_v_dups) + 2);
            }
            goto __pyx_L21;
          }

     488:             elif tiebreak == TIEBREAK_MAX:

          /* "pandas/algos.pyx":488
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:             # <<<<<<<<<<<<<<
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1
     */
          __pyx_t_21 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MAX) != 0);
          if (__pyx_t_21) {

     489:                 for j in range(i - dups + 1, i + 1):

            /* "pandas/algos.pyx":489
     *                     ranks[argsorted[j]] = i - dups + 2
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):             # <<<<<<<<<<<<<<
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     */
            __pyx_t_22 = (__pyx_v_i + 1);
            for (__pyx_t_23 = ((__pyx_v_i - __pyx_v_dups) + 1); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) {
              __pyx_v_j = __pyx_t_23;

     490:                     ranks[argsorted[j]] = i + 1

              /* "pandas/algos.pyx":490
     *             elif tiebreak == TIEBREAK_MAX:
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1             # <<<<<<<<<<<<<<
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 raise ValueError('first not supported for non-numeric data')
     */
              __pyx_t_28 = __pyx_v_j;
              __pyx_t_3 = -1;
              if (__pyx_t_28 < 0) {
                __pyx_t_28 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                if (unlikely(__pyx_t_28 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_29 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_argsorted.diminfo[0].strides));
              __pyx_t_3 = -1;
              if (__pyx_t_29 < 0) {
                __pyx_t_29 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                if (unlikely(__pyx_t_29 < 0)) __pyx_t_3 = 0;
              } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
              if (unlikely(__pyx_t_3 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_3);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_ranks.diminfo[0].strides) = (__pyx_v_i + 1);
            }
            goto __pyx_L21;
          }

     491:             elif tiebreak == TIEBREAK_FIRST:

          /* "pandas/algos.pyx":491
     *                 for j in range(i - dups + 1, i + 1):
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *                 raise ValueError('first not supported for non-numeric data')
     *             sum_ranks = dups = 0
     */
          __pyx_t_21 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
          if (__pyx_t_21) {

     492:                 raise ValueError('first not supported for non-numeric data')

            /* "pandas/algos.pyx":492
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 raise ValueError('first not supported for non-numeric data')             # <<<<<<<<<<<<<<
     *             sum_ranks = dups = 0
     *     return ranks
     */
            __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_L21:;

      /* "pandas/algos.pyx":492
     *                     ranks[argsorted[j]] = i + 1
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 raise ValueError('first not supported for non-numeric data')             # <<<<<<<<<<<<<<
     *             sum_ranks = dups = 0
     *     return ranks
     */
      __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_first_not_supported_for_non_nume); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__19);
      __Pyx_GIVEREF(__pyx_tuple__19);

     493:             sum_ranks = dups = 0

          /* "pandas/algos.pyx":493
     *             elif tiebreak == TIEBREAK_FIRST:
     *                 raise ValueError('first not supported for non-numeric data')
     *             sum_ranks = dups = 0             # <<<<<<<<<<<<<<
     *     return ranks
     *
     */
          __pyx_v_sum_ranks = 0;
          __pyx_v_dups = 0;
          goto __pyx_L20;
        }
        __pyx_L20:;
        __pyx_L17_continue:;
      }

     494:     return ranks

      /* "pandas/algos.pyx":494
     *                 raise ValueError('first not supported for non-numeric data')
     *             sum_ranks = dups = 0
     *     return ranks             # <<<<<<<<<<<<<<
     *
     * cdef inline are_diff(object left, object right):
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
      __pyx_r = ((PyObject *)__pyx_v_ranks);
      goto __pyx_L0;

     495:

     496: cdef inline are_diff(object left, object right):

    /* "pandas/algos.pyx":496
     *     return ranks
     *
     * cdef inline are_diff(object left, object right):             # <<<<<<<<<<<<<<
     *     try:
     *         return fabs(left - right) > FP_ERR
     */

    static CYTHON_INLINE PyObject *__pyx_f_6pandas_5algos_are_diff(PyObject *__pyx_v_left, PyObject *__pyx_v_right) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("are_diff", 0);

      /* "pandas/algos.pyx":496
     *     return ranks
     *
     * cdef inline are_diff(object left, object right):             # <<<<<<<<<<<<<<
     *     try:
     *         return fabs(left - right) > FP_ERR
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_9);
      __Pyx_AddTraceback("pandas.algos.are_diff", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     497:     try:

      /* "pandas/algos.pyx":497
     *
     * cdef inline are_diff(object left, object right):
     *     try:             # <<<<<<<<<<<<<<
     *         return fabs(left - right) > FP_ERR
     *     except TypeError:
     */
      {
        /*try:*/ {

     498:         return fabs(left - right) > FP_ERR

          /* "pandas/algos.pyx":498
     * cdef inline are_diff(object left, object right):
     *     try:
     *         return fabs(left - right) > FP_ERR             # <<<<<<<<<<<<<<
     *     except TypeError:
     *         return left != right
     */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_4 = PyNumber_Subtract(__pyx_v_left, __pyx_v_right); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyBool_FromLong((fabs(__pyx_t_5) > __pyx_v_6pandas_5algos_FP_ERR)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_r = __pyx_t_4;
          __pyx_t_4 = 0;
          goto __pyx_L7_try_return;
        }
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L10_try_end;
        __pyx_L3_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

     499:     except TypeError:

        /* "pandas/algos.pyx":499
     *     try:
     *         return fabs(left - right) > FP_ERR
     *     except TypeError:             # <<<<<<<<<<<<<<
     *         return left != right
     *
     */
        __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
        if (__pyx_t_6) {
          __Pyx_AddTraceback("pandas.algos.are_diff", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GOTREF(__pyx_t_8);

     500:         return left != right

          /* "pandas/algos.pyx":500
     *         return fabs(left - right) > FP_ERR
     *     except TypeError:
     *         return left != right             # <<<<<<<<<<<<<<
     *
     * _return_false = lambda self, other: False
     */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_9 = PyObject_RichCompare(__pyx_v_left, __pyx_v_right, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
          __pyx_r = __pyx_t_9;
          __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          goto __pyx_L6_except_return;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          goto __pyx_L4_exception_handled;
        }
        goto __pyx_L5_except_error;
        __pyx_L5_except_error:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L1_error;
        __pyx_L7_try_return:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L0;
        __pyx_L6_except_return:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L0;
        __pyx_L4_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        __pyx_L10_try_end:;
      }

     501:

     502: _return_false = lambda self, other: False

    /* "pandas/algos.pyx":502
     *         return left != right
     *
     * _return_false = lambda self, other: False             # <<<<<<<<<<<<<<
     * _return_true = lambda self, other: True
     *
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_494lambda1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_494lambda1 = {__Pyx_NAMESTR("lambda1"), (PyCFunction)__pyx_pw_6pandas_5algos_494lambda1, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_494lambda1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      CYTHON_UNUSED PyObject *__pyx_v_self = 0;
      CYTHON_UNUSED PyObject *__pyx_v_other = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_other,0};
        PyObject* values[2] = {0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("lambda1", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda1") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        }
        __pyx_v_self = values[0];
        __pyx_v_other = values[1];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("lambda1", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_lambda_funcdef_6pandas_5algos_lambda1(__pyx_self, __pyx_v_self, __pyx_v_other);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_lambda_funcdef_6pandas_5algos_lambda1(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_other) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("lambda1", 0);
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":502
     *         return left != right
     *
     * _return_false = lambda self, other: False             # <<<<<<<<<<<<<<
     * _return_true = lambda self, other: True
     *
     */
      __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6pandas_5algos_494lambda1, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_pandas_algos, PyModule_GetDict(__pyx_m), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_return_false, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     503: _return_true = lambda self, other: True

    /* "pandas/algos.pyx":503
     *
     * _return_false = lambda self, other: False
     * _return_true = lambda self, other: True             # <<<<<<<<<<<<<<
     *
     * class Infinity(object):
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_495lambda2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_495lambda2 = {__Pyx_NAMESTR("lambda2"), (PyCFunction)__pyx_pw_6pandas_5algos_495lambda2, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_495lambda2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      CYTHON_UNUSED PyObject *__pyx_v_self = 0;
      CYTHON_UNUSED PyObject *__pyx_v_other = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_other,0};
        PyObject* values[2] = {0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("lambda2", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda2") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        }
        __pyx_v_self = values[0];
        __pyx_v_other = values[1];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("lambda2", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_lambda_funcdef_6pandas_5algos_lambda2(__pyx_self, __pyx_v_self, __pyx_v_other);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_lambda_funcdef_6pandas_5algos_lambda2(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_other) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("lambda2", 0);
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":503
     *
     * _return_false = lambda self, other: False
     * _return_true = lambda self, other: True             # <<<<<<<<<<<<<<
     *
     * class Infinity(object):
     */
      __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6pandas_5algos_495lambda2, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_pandas_algos, PyModule_GetDict(__pyx_m), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_return_true, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     504:

     505: class Infinity(object):

      /* "pandas/algos.pyx":505
     * _return_true = lambda self, other: True
     *
     * class Infinity(object):             # <<<<<<<<<<<<<<
     *
     *     __lt__ = _return_false
     */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_builtin_object);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_object);
      __Pyx_GIVEREF(__pyx_builtin_object);
      __pyx_t_12 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_12, __pyx_t_3, __pyx_n_s_Infinity, __pyx_n_s_Infinity, (PyObject *) NULL, __pyx_n_s_pandas_algos, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);

      /* "pandas/algos.pyx":505
     * _return_true = lambda self, other: True
     *
     * class Infinity(object):             # <<<<<<<<<<<<<<
     *
     *     __lt__ = _return_false
     */
      __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_12, __pyx_n_s_Infinity, __pyx_t_3, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_Infinity, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     506:

     507:     __lt__ = _return_false

      /* "pandas/algos.pyx":507
     * class Infinity(object):
     *
     *     __lt__ = _return_false             # <<<<<<<<<<<<<<
     *     __le__ = _return_false
     *     __eq__ = _return_false
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_lt, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     508:     __le__ = _return_false

      /* "pandas/algos.pyx":508
     *
     *     __lt__ = _return_false
     *     __le__ = _return_false             # <<<<<<<<<<<<<<
     *     __eq__ = _return_false
     *     __ne__ = _return_true
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_le, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     509:     __eq__ = _return_false

      /* "pandas/algos.pyx":509
     *     __lt__ = _return_false
     *     __le__ = _return_false
     *     __eq__ = _return_false             # <<<<<<<<<<<<<<
     *     __ne__ = _return_true
     *     __gt__ = _return_true
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_eq, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     510:     __ne__ = _return_true

      /* "pandas/algos.pyx":510
     *     __le__ = _return_false
     *     __eq__ = _return_false
     *     __ne__ = _return_true             # <<<<<<<<<<<<<<
     *     __gt__ = _return_true
     *     __ge__ = _return_true
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_ne, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     511:     __gt__ = _return_true

      /* "pandas/algos.pyx":511
     *     __eq__ = _return_false
     *     __ne__ = _return_true
     *     __gt__ = _return_true             # <<<<<<<<<<<<<<
     *     __ge__ = _return_true
     *     __cmp__ = _return_false
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_gt, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     512:     __ge__ = _return_true

      /* "pandas/algos.pyx":512
     *     __ne__ = _return_true
     *     __gt__ = _return_true
     *     __ge__ = _return_true             # <<<<<<<<<<<<<<
     *     __cmp__ = _return_false
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_ge, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     513:     __cmp__ = _return_false

      /* "pandas/algos.pyx":513
     *     __gt__ = _return_true
     *     __ge__ = _return_true
     *     __cmp__ = _return_false             # <<<<<<<<<<<<<<
     *
     * class NegInfinity(object):
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_cmp, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     514:

     515: class NegInfinity(object):

      /* "pandas/algos.pyx":515
     *     __cmp__ = _return_false
     *
     * class NegInfinity(object):             # <<<<<<<<<<<<<<
     *
     *     __lt__ = _return_true
     */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_builtin_object);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_object);
      __Pyx_GIVEREF(__pyx_builtin_object);
      __pyx_t_12 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_12, __pyx_t_3, __pyx_n_s_NegInfinity, __pyx_n_s_NegInfinity, (PyObject *) NULL, __pyx_n_s_pandas_algos, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);

      /* "pandas/algos.pyx":515
     *     __cmp__ = _return_false
     *
     * class NegInfinity(object):             # <<<<<<<<<<<<<<
     *
     *     __lt__ = _return_true
     */
      __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_12, __pyx_n_s_NegInfinity, __pyx_t_3, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_NegInfinity, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     516:

     517:     __lt__ = _return_true

      /* "pandas/algos.pyx":517
     * class NegInfinity(object):
     *
     *     __lt__ = _return_true             # <<<<<<<<<<<<<<
     *     __le__ = _return_true
     *     __eq__ = _return_false
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_lt, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     518:     __le__ = _return_true

      /* "pandas/algos.pyx":518
     *
     *     __lt__ = _return_true
     *     __le__ = _return_true             # <<<<<<<<<<<<<<
     *     __eq__ = _return_false
     *     __ne__ = _return_true
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_le, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     519:     __eq__ = _return_false

      /* "pandas/algos.pyx":519
     *     __lt__ = _return_true
     *     __le__ = _return_true
     *     __eq__ = _return_false             # <<<<<<<<<<<<<<
     *     __ne__ = _return_true
     *     __gt__ = _return_false
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_eq, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     520:     __ne__ = _return_true

      /* "pandas/algos.pyx":520
     *     __le__ = _return_true
     *     __eq__ = _return_false
     *     __ne__ = _return_true             # <<<<<<<<<<<<<<
     *     __gt__ = _return_false
     *     __ge__ = _return_false
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_ne, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     521:     __gt__ = _return_false

      /* "pandas/algos.pyx":521
     *     __eq__ = _return_false
     *     __ne__ = _return_true
     *     __gt__ = _return_false             # <<<<<<<<<<<<<<
     *     __ge__ = _return_false
     *     __cmp__ = _return_true
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_gt, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     522:     __ge__ = _return_false

      /* "pandas/algos.pyx":522
     *     __ne__ = _return_true
     *     __gt__ = _return_false
     *     __ge__ = _return_false             # <<<<<<<<<<<<<<
     *     __cmp__ = _return_true
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_false); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_ge, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     523:     __cmp__ = _return_true

      /* "pandas/algos.pyx":523
     *     __gt__ = _return_false
     *     __ge__ = _return_false
     *     __cmp__ = _return_true             # <<<<<<<<<<<<<<
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_return_true); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_cmp, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     524:

     525: def rank_2d_generic(object in_arr, axis=0, ties_method='average',

    /* "pandas/algos.pyx":525
     *     __cmp__ = _return_true
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_11rank_2d_generic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_10rank_2d_generic[] = "\n    Fast NaN-friendly version of scipy.stats.rankdata\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_11rank_2d_generic = {__Pyx_NAMESTR("rank_2d_generic"), (PyCFunction)__pyx_pw_6pandas_5algos_11rank_2d_generic, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_10rank_2d_generic)};
    static PyObject *__pyx_pw_6pandas_5algos_11rank_2d_generic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_in_arr = 0;
      PyObject *__pyx_v_axis = 0;
      PyObject *__pyx_v_ties_method = 0;
      PyObject *__pyx_v_ascending = 0;
      PyObject *__pyx_v_na_option = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_2d_generic (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_arr,&__pyx_n_s_axis,&__pyx_n_s_ties_method,&__pyx_n_s_ascending,&__pyx_n_s_na_option,0};
        PyObject* values[5] = {0,0,0,0,0};
        values[1] = ((PyObject *)__pyx_int_0);
        values[2] = ((PyObject *)__pyx_n_s_average);

      /* "pandas/algos.pyx":525
     *     __cmp__ = _return_true
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_10rank_2d_generic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_arr, PyObject *__pyx_v_axis, PyObject *__pyx_v_ties_method, PyObject *__pyx_v_ascending, PyObject *__pyx_v_na_option) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_z;
      Py_ssize_t __pyx_v_k;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_infs;
      Py_ssize_t __pyx_v_dups;
      PyArrayObject *__pyx_v_ranks = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_argsorted = 0;
      PyObject *__pyx_v_val = 0;
      PyObject *__pyx_v_nan_value = 0;
      __pyx_t_5numpy_float64_t __pyx_v_sum_ranks;
      int __pyx_v_tiebreak;
      int __pyx_v_keep_na;
      PyObject *__pyx_v_mask = NULL;
      PyObject *__pyx_v__as = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_argsorted;
      __Pyx_Buffer __pyx_pybuffer_argsorted;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_ranks;
      __Pyx_Buffer __pyx_pybuffer_ranks;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("rank_2d_generic", 0);
      __Pyx_INCREF(__pyx_v_in_arr);
      __pyx_pybuffer_ranks.pybuffer.buf = NULL;
      __pyx_pybuffer_ranks.refcount = 0;
      __pyx_pybuffernd_ranks.data = NULL;
      __pyx_pybuffernd_ranks.rcbuffer = &__pyx_pybuffer_ranks;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_argsorted.pybuffer.buf = NULL;
      __pyx_pybuffer_argsorted.refcount = 0;
      __pyx_pybuffernd_argsorted.data = NULL;
      __pyx_pybuffernd_argsorted.rcbuffer = &__pyx_pybuffer_argsorted;

      /* "pandas/algos.pyx":525
     *     __cmp__ = _return_true
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_t_18);
      __Pyx_XDECREF(__pyx_t_19);
      __Pyx_XDECREF(__pyx_t_20);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.rank_2d_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_ranks);
      __Pyx_XDECREF((PyObject *)__pyx_v_values);
      __Pyx_XDECREF((PyObject *)__pyx_v_argsorted);
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XDECREF(__pyx_v_nan_value);
      __Pyx_XDECREF(__pyx_v_mask);
      __Pyx_XDECREF(__pyx_v__as);
      __Pyx_XDECREF(__pyx_v_in_arr);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":525
     *     __cmp__ = _return_true
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_tuple__226 = PyTuple_Pack(22, __pyx_n_s_in_arr, __pyx_n_s_axis, __pyx_n_s_ties_method, __pyx_n_s_ascending, __pyx_n_s_na_option, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_z, __pyx_n_s_k, __pyx_n_s_n, __pyx_n_s_infs, __pyx_n_s_dups, __pyx_n_s_ranks, __pyx_n_s_values, __pyx_n_s_argsorted, __pyx_n_s_val, __pyx_n_s_nan_value, __pyx_n_s_sum_ranks, __pyx_n_s_tiebreak, __pyx_n_s_keep_na, __pyx_n_s_mask, __pyx_n_s_as); if (unlikely(!__pyx_tuple__226)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__226);
      __Pyx_GIVEREF(__pyx_tuple__226);

      /* "pandas/algos.pyx":525
     *     __cmp__ = _return_true
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',             # <<<<<<<<<<<<<<
     *                     ascending=True, na_option='keep'):
     *     """
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_11rank_2d_generic, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rank_2d_generic, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__227 = (PyObject*)__Pyx_PyCode_New(5, 0, 22, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__226, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_rank_2d_generic, 525, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__227)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     526:                     ascending=True, na_option='keep'):

        /* "pandas/algos.pyx":526
     *
     * def rank_2d_generic(object in_arr, axis=0, ties_method='average',
     *                     ascending=True, na_option='keep'):             # <<<<<<<<<<<<<<
     *     """
     *     Fast NaN-friendly version of scipy.stats.rankdata
     */
        values[3] = ((PyObject *)Py_True);
        values[4] = ((PyObject *)__pyx_n_s_keep);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arr)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ties_method);
              if (value) { values[2] = value; kw_args--; }
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ascending);
              if (value) { values[3] = value; kw_args--; }
            }
            case  4:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_na_option);
              if (value) { values[4] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rank_2d_generic") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_in_arr = values[0];
        __pyx_v_axis = values[1];
        __pyx_v_ties_method = values[2];
        __pyx_v_ascending = values[3];
        __pyx_v_na_option = values[4];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("rank_2d_generic", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.rank_2d_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_10rank_2d_generic(__pyx_self, __pyx_v_in_arr, __pyx_v_axis, __pyx_v_ties_method, __pyx_v_ascending, __pyx_v_na_option);

     527:     """

     528:     Fast NaN-friendly version of scipy.stats.rankdata

     529:     """

     530:

     531:     cdef:

     532:         Py_ssize_t i, j, z, k, n, infs, dups = 0

      /* "pandas/algos.pyx":532
     *
     *     cdef:
     *         Py_ssize_t i, j, z, k, n, infs, dups = 0             # <<<<<<<<<<<<<<
     *         ndarray[float64_t, ndim=2] ranks
     *         ndarray[object, ndim=2] values
     */
      __pyx_v_dups = 0;

     533:         ndarray[float64_t, ndim=2] ranks

     534:         ndarray[object, ndim=2] values

     535:         ndarray[int64_t, ndim=2] argsorted

     536:         object val, nan_value

     537:         float64_t sum_ranks = 0

      /* "pandas/algos.pyx":537
     *         ndarray[int64_t, ndim=2] argsorted
     *         object val, nan_value
     *         float64_t sum_ranks = 0             # <<<<<<<<<<<<<<
     *         int tiebreak = 0
     *         bint keep_na = 0
     */
      __pyx_v_sum_ranks = 0.0;

     538:         int tiebreak = 0

      /* "pandas/algos.pyx":538
     *         object val, nan_value
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0             # <<<<<<<<<<<<<<
     *         bint keep_na = 0
     *
     */
      __pyx_v_tiebreak = 0;

     539:         bint keep_na = 0

      /* "pandas/algos.pyx":539
     *         float64_t sum_ranks = 0
     *         int tiebreak = 0
     *         bint keep_na = 0             # <<<<<<<<<<<<<<
     *
     *     tiebreak = tiebreakers[ties_method]
     */
      __pyx_v_keep_na = 0;

     540:

     541:     tiebreak = tiebreakers[ties_method]

      /* "pandas/algos.pyx":541
     *         bint keep_na = 0
     *
     *     tiebreak = tiebreakers[ties_method]             # <<<<<<<<<<<<<<
     *
     *     keep_na = na_option == 'keep'
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tiebreakers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_ties_method); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tiebreak = __pyx_t_3;

     542:

     543:     keep_na = na_option == 'keep'

      /* "pandas/algos.pyx":543
     *     tiebreak = tiebreakers[ties_method]
     *
     *     keep_na = na_option == 'keep'             # <<<<<<<<<<<<<<
     *
     *     in_arr = np.asarray(in_arr)
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_keep, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_keep_na = __pyx_t_4;

     544:

     545:     in_arr = np.asarray(in_arr)

      /* "pandas/algos.pyx":545
     *     keep_na = na_option == 'keep'
     *
     *     in_arr = np.asarray(in_arr)             # <<<<<<<<<<<<<<
     *
     *     if axis == 0:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_in_arr);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_in_arr);
      __Pyx_GIVEREF(__pyx_v_in_arr);
      __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_in_arr, __pyx_t_5);
      __pyx_t_5 = 0;

     546:

     547:     if axis == 0:

      /* "pandas/algos.pyx":547
     *     in_arr = np.asarray(in_arr)
     *
     *     if axis == 0:             # <<<<<<<<<<<<<<
     *         values = in_arr.T.copy()
     *     else:
     */
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     548:         values = in_arr.T.copy()

        /* "pandas/algos.pyx":548
     *
     *     if axis == 0:
     *         values = in_arr.T.copy()             # <<<<<<<<<<<<<<
     *     else:
     *         values = in_arr.copy()
     */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_in_arr, __pyx_n_s_T); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_values = ((PyArrayObject *)__pyx_t_5);
        __pyx_t_5 = 0;
        goto __pyx_L3;
      }
      /*else*/ {

     549:     else:

     550:         values = in_arr.copy()

        /* "pandas/algos.pyx":550
     *         values = in_arr.T.copy()
     *     else:
     *         values = in_arr.copy()             # <<<<<<<<<<<<<<
     *
     *     if values.dtype != np.object_:
     */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_in_arr, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_values = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
      }
      __pyx_L3:;

     551:

     552:     if values.dtype != np.object_:

      /* "pandas/algos.pyx":552
     *         values = in_arr.copy()
     *
     *     if values.dtype != np.object_:             # <<<<<<<<<<<<<<
     *         values = values.astype('O')
     *
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_object_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     553:         values = values.astype('O')

        /* "pandas/algos.pyx":553
     *
     *     if values.dtype != np.object_:
     *         values = values.astype('O')             # <<<<<<<<<<<<<<
     *
     *     if ascending ^ (na_option == 'top'):
     */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
          __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_3 < 0)) {
            PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            }
          }
          __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __Pyx_DECREF_SET(__pyx_v_values, ((PyArrayObject *)__pyx_t_1));
        __pyx_t_1 = 0;
        goto __pyx_L4;
      }
      __pyx_L4:;

      /* "pandas/algos.pyx":553
     *
     *     if values.dtype != np.object_:
     *         values = values.astype('O')             # <<<<<<<<<<<<<<
     *
     *     if ascending ^ (na_option == 'top'):
     */
      __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_O); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__20);
      __Pyx_GIVEREF(__pyx_tuple__20);

     554:

     555:     if ascending ^ (na_option == 'top'):

      /* "pandas/algos.pyx":555
     *         values = values.astype('O')
     *
     *     if ascending ^ (na_option == 'top'):             # <<<<<<<<<<<<<<
     *         # always greater than everything
     *         nan_value = Infinity()
     */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_na_option, __pyx_n_s_top, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyNumber_Xor(__pyx_v_ascending, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

     556:         # always greater than everything

     557:         nan_value = Infinity()

        /* "pandas/algos.pyx":557
     *     if ascending ^ (na_option == 'top'):
     *         # always greater than everything
     *         nan_value = Infinity()             # <<<<<<<<<<<<<<
     *     else:
     *         nan_value = NegInfinity()
     */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Infinity); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_v_nan_value = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L5;
      }
      /*else*/ {

     558:     else:

     559:         nan_value = NegInfinity()

        /* "pandas/algos.pyx":559
     *         nan_value = Infinity()
     *     else:
     *         nan_value = NegInfinity()             # <<<<<<<<<<<<<<
     *
     *     mask = lib.isnullobj2d(values)
     */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NegInfinity); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_nan_value = __pyx_t_5;
        __pyx_t_5 = 0;
      }
      __pyx_L5:;

     560:

     561:     mask = lib.isnullobj2d(values)

      /* "pandas/algos.pyx":561
     *         nan_value = NegInfinity()
     *
     *     mask = lib.isnullobj2d(values)             # <<<<<<<<<<<<<<
     *     np.putmask(values, mask, nan_value)
     *
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isnullobj2d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_mask = __pyx_t_2;
      __pyx_t_2 = 0;

     562:     np.putmask(values, mask, nan_value)

      /* "pandas/algos.pyx":562
     *
     *     mask = lib.isnullobj2d(values)
     *     np.putmask(values, mask, nan_value)             # <<<<<<<<<<<<<<
     *
     *     n, k = (<object> values).shape
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_putmask); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __Pyx_INCREF(__pyx_v_mask);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_mask);
      __Pyx_GIVEREF(__pyx_v_mask);
      __Pyx_INCREF(__pyx_v_nan_value);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_nan_value);
      __Pyx_GIVEREF(__pyx_v_nan_value);
      __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     563:

     564:     n, k = (<object> values).shape

      /* "pandas/algos.pyx":564
     *     np.putmask(values, mask, nan_value)
     *
     *     n, k = (<object> values).shape             # <<<<<<<<<<<<<<
     *     ranks = np.empty((n, k), dtype='f8')
     *
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_n = __pyx_t_12;
      __pyx_v_k = __pyx_t_13;

     565:     ranks = np.empty((n, k), dtype='f8')

      /* "pandas/algos.pyx":565
     *
     *     n, k = (<object> values).shape
     *     ranks = np.empty((n, k), dtype='f8')             # <<<<<<<<<<<<<<
     *
     *     try:
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, __pyx_n_s_f8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ranks.rcbuffer->pybuffer, (PyObject*)__pyx_v_ranks, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
          }
        }
        __pyx_pybuffernd_ranks.diminfo[0].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ranks.diminfo[0].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ranks.diminfo[1].strides = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ranks.diminfo[1].shape = __pyx_pybuffernd_ranks.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_ranks = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     566:

     567:     try:

      /* "pandas/algos.pyx":567
     *     ranks = np.empty((n, k), dtype='f8')
     *
     *     try:             # <<<<<<<<<<<<<<
     *         _as = values.argsort(1)
     *     except TypeError:
     */
      {
        /*try:*/ {

     568:         _as = values.argsort(1)

          /* "pandas/algos.pyx":568
     *
     *     try:
     *         _as = values.argsort(1)             # <<<<<<<<<<<<<<
     *     except TypeError:
     *         values = in_arr
     */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_argsort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = PyObject_Call(__pyx_t_1, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v__as = __pyx_t_10;
          __pyx_t_10 = 0;
        }
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L15_try_end;
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "pandas/algos.pyx":568
     *
     *     try:
     *         _as = values.argsort(1)             # <<<<<<<<<<<<<<
     *     except TypeError:
     *         values = in_arr
     */
      __pyx_tuple__21 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__21);
      __Pyx_GIVEREF(__pyx_tuple__21);

     569:     except TypeError:

        /* "pandas/algos.pyx":569
     *     try:
     *         _as = values.argsort(1)
     *     except TypeError:             # <<<<<<<<<<<<<<
     *         values = in_arr
     *         for i in range(len(values)):
     */
        __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
        if (__pyx_t_3) {
          __Pyx_AddTraceback("pandas.algos.rank_2d_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_2);

     570:         values = in_arr

          /* "pandas/algos.pyx":570
     *         _as = values.argsort(1)
     *     except TypeError:
     *         values = in_arr             # <<<<<<<<<<<<<<
     *         for i in range(len(values)):
     *             ranks[i] = rank_1d_generic(in_arr[i],
     */
          if (!(likely(((__pyx_v_in_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_in_arr, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
          __pyx_t_5 = __pyx_v_in_arr;
          __Pyx_INCREF(__pyx_t_5);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
            __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_5), &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
            if (unlikely(__pyx_t_3 < 0)) {
              PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
              }
            }
            __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
            if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
          }
          __Pyx_DECREF_SET(__pyx_v_values, ((PyArrayObject *)__pyx_t_5));
          __pyx_t_5 = 0;

     571:         for i in range(len(values)):

          /* "pandas/algos.pyx":571
     *     except TypeError:
     *         values = in_arr
     *         for i in range(len(values)):             # <<<<<<<<<<<<<<
     *             ranks[i] = rank_1d_generic(in_arr[i],
     *                                        ties_method=ties_method,
     */
          __pyx_t_13 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
          for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_13; __pyx_t_12+=1) {
            __pyx_v_i = __pyx_t_12;

     572:             ranks[i] = rank_1d_generic(in_arr[i],

            /* "pandas/algos.pyx":572
     *         values = in_arr
     *         for i in range(len(values)):
     *             ranks[i] = rank_1d_generic(in_arr[i],             # <<<<<<<<<<<<<<
     *                                        ties_method=ties_method,
     *                                        ascending=ascending)
     */
            __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_rank_1d_generic); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_in_arr, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(__pyx_t_18 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;};
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_19);
            PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            __pyx_t_18 = 0;
            __pyx_t_18 = PyDict_New(); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_18);

            /* "pandas/algos.pyx":572
     *         values = in_arr
     *         for i in range(len(values)):
     *             ranks[i] = rank_1d_generic(in_arr[i],             # <<<<<<<<<<<<<<
     *                                        ties_method=ties_method,
     *                                        ascending=ascending)
     */
            __pyx_t_20 = PyObject_Call(__pyx_t_5, __pyx_t_19, __pyx_t_18); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_20);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_ranks), __pyx_v_i, __pyx_t_20, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          }

     573:                                        ties_method=ties_method,

            /* "pandas/algos.pyx":573
     *         for i in range(len(values)):
     *             ranks[i] = rank_1d_generic(in_arr[i],
     *                                        ties_method=ties_method,             # <<<<<<<<<<<<<<
     *                                        ascending=ascending)
     *         if axis == 0:
     */
            if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_ties_method, __pyx_v_ties_method) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}

     574:                                        ascending=ascending)

            /* "pandas/algos.pyx":574
     *             ranks[i] = rank_1d_generic(in_arr[i],
     *                                        ties_method=ties_method,
     *                                        ascending=ascending)             # <<<<<<<<<<<<<<
     *         if axis == 0:
     *             return ranks.T
     */
            if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_ascending, __pyx_v_ascending) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}

     575:         if axis == 0:

          /* "pandas/algos.pyx":575
     *                                        ties_method=ties_method,
     *                                        ascending=ascending)
     *         if axis == 0:             # <<<<<<<<<<<<<<
     *             return ranks.T
     *         else:
     */
          __pyx_t_20 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_20); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
          __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_20); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (__pyx_t_4) {

     576:             return ranks.T

            /* "pandas/algos.pyx":576
     *                                        ascending=ascending)
     *         if axis == 0:
     *             return ranks.T             # <<<<<<<<<<<<<<
     *         else:
     *             return ranks
     */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_20 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ranks), __pyx_n_s_T); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_20);
            __pyx_r = __pyx_t_20;
            __pyx_t_20 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L11_except_return;
          }
          /*else*/ {

     577:         else:

     578:             return ranks

            /* "pandas/algos.pyx":578
     *             return ranks.T
     *         else:
     *             return ranks             # <<<<<<<<<<<<<<
     *
     *     if not ascending:
     */
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
            __pyx_r = ((PyObject *)__pyx_v_ranks);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L11_except_return;
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L9_exception_handled;
        }
        goto __pyx_L10_except_error;
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L1_error;
        __pyx_L11_except_return:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L0;
        __pyx_L9_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        __pyx_L15_try_end:;
      }

     579:

     580:     if not ascending:

      /* "pandas/algos.pyx":580
     *             return ranks
     *
     *     if not ascending:             # <<<<<<<<<<<<<<
     *         _as = _as[:, ::-1]
     *
     */
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_ascending); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_21 = ((!__pyx_t_4) != 0);
      if (__pyx_t_21) {

     581:         _as = _as[:, ::-1]

      /* "pandas/algos.pyx":581
     *
     *     if not ascending:
     *         _as = _as[:, ::-1]             # <<<<<<<<<<<<<<
     *
     *     values = _take_2d_object(values, _as)
     */
      __pyx_slice__22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__22);
      __Pyx_GIVEREF(__pyx_slice__22);
      __pyx_slice__23 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__23);
      __Pyx_GIVEREF(__pyx_slice__23);

        /* "pandas/algos.pyx":581
     *
     *     if not ascending:
     *         _as = _as[:, ::-1]             # <<<<<<<<<<<<<<
     *
     *     values = _take_2d_object(values, _as)
     */
        __pyx_t_2 = PyObject_GetItem(__pyx_v__as, __pyx_tuple__24); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF_SET(__pyx_v__as, __pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L21;
      }
      __pyx_L21:;
      __pyx_tuple__24 = PyTuple_Pack(2, __pyx_slice__22, __pyx_slice__23); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__24);
      __Pyx_GIVEREF(__pyx_tuple__24);

     582:

     583:     values = _take_2d_object(values, _as)

      /* "pandas/algos.pyx":583
     *         _as = _as[:, ::-1]
     *
     *     values = _take_2d_object(values, _as)             # <<<<<<<<<<<<<<
     *     argsorted = _as.astype('i8')
     *
     */
      __pyx_t_2 = __pyx_f_6pandas_5algos__take_2d_object(((PyArrayObject *)__pyx_v_values), __pyx_v__as); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
          }
        }
        __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_values, ((PyArrayObject *)__pyx_t_2));
      __pyx_t_2 = 0;

     584:     argsorted = _as.astype('i8')

      /* "pandas/algos.pyx":584
     *
     *     values = _take_2d_object(values, _as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v__as, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_22 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer);
        __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_3 < 0)) {
          PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          }
        }
        __pyx_pybuffernd_argsorted.diminfo[0].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_argsorted.diminfo[0].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_argsorted.diminfo[1].strides = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_argsorted.diminfo[1].shape = __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_22 = 0;
      __pyx_v_argsorted = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "pandas/algos.pyx":584
     *
     *     values = _take_2d_object(values, _as)
     *     argsorted = _as.astype('i8')             # <<<<<<<<<<<<<<
     *
     *     for i in range(n):
     */
      __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__25);
      __Pyx_GIVEREF(__pyx_tuple__25);

     585:

     586:     for i in range(n):

      /* "pandas/algos.pyx":586
     *     argsorted = _as.astype('i8')
     *
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         dups = sum_ranks = infs = 0
     *         for j in range(k):
     */
      __pyx_t_13 = __pyx_v_n;
      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_13; __pyx_t_12+=1) {
        __pyx_v_i = __pyx_t_12;

     587:         dups = sum_ranks = infs = 0

        /* "pandas/algos.pyx":587
     *
     *     for i in range(n):
     *         dups = sum_ranks = infs = 0             # <<<<<<<<<<<<<<
     *         for j in range(k):
     *             val = values[i, j]
     */
        __pyx_v_dups = 0;
        __pyx_v_sum_ranks = 0;
        __pyx_v_infs = 0;

     588:         for j in range(k):

        /* "pandas/algos.pyx":588
     *     for i in range(n):
     *         dups = sum_ranks = infs = 0
     *         for j in range(k):             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *             if val is nan_value and keep_na:
     */
        __pyx_t_23 = __pyx_v_k;
        for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) {
          __pyx_v_j = __pyx_t_24;

     589:             val = values[i, j]

          /* "pandas/algos.pyx":589
     *         dups = sum_ranks = infs = 0
     *         for j in range(k):
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *             if val is nan_value and keep_na:
     *                 ranks[i, argsorted[i, j]] = nan
     */
          __pyx_t_25 = __pyx_v_i;
          __pyx_t_26 = __pyx_v_j;
          __pyx_t_3 = -1;
          if (__pyx_t_25 < 0) {
            __pyx_t_25 += __pyx_pybuffernd_values.diminfo[0].shape;
            if (unlikely(__pyx_t_25 < 0)) __pyx_t_3 = 0;
          } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_3 = 0;
          if (__pyx_t_26 < 0) {
            __pyx_t_26 += __pyx_pybuffernd_values.diminfo[1].shape;
            if (unlikely(__pyx_t_26 < 0)) __pyx_t_3 = 1;
          } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_3 = 1;
          if (unlikely(__pyx_t_3 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_3);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_1 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_values.diminfo[1].strides);
          __Pyx_INCREF((PyObject*)__pyx_t_1);
          __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_1);
          __pyx_t_1 = 0;

     590:             if val is nan_value and keep_na:

          /* "pandas/algos.pyx":590
     *         for j in range(k):
     *             val = values[i, j]
     *             if val is nan_value and keep_na:             # <<<<<<<<<<<<<<
     *                 ranks[i, argsorted[i, j]] = nan
     *                 infs += 1
     */
          __pyx_t_21 = (__pyx_v_val == __pyx_v_nan_value);
          if ((__pyx_t_21 != 0)) {
            __pyx_t_4 = (__pyx_v_keep_na != 0);
          } else {
            __pyx_t_4 = (__pyx_t_21 != 0);
          }
          if (__pyx_t_4) {

     591:                 ranks[i, argsorted[i, j]] = nan

            /* "pandas/algos.pyx":591
     *             val = values[i, j]
     *             if val is nan_value and keep_na:
     *                 ranks[i, argsorted[i, j]] = nan             # <<<<<<<<<<<<<<
     *                 infs += 1
     *                 continue
     */
            __pyx_t_27 = __pyx_v_i;
            __pyx_t_28 = __pyx_v_j;
            __pyx_t_3 = -1;
            if (__pyx_t_27 < 0) {
              __pyx_t_27 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
              if (unlikely(__pyx_t_27 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_28 < 0) {
              __pyx_t_28 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
              if (unlikely(__pyx_t_28 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_29 = __pyx_v_i;
            __pyx_t_30 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_argsorted.diminfo[1].strides));
            __pyx_t_3 = -1;
            if (__pyx_t_29 < 0) {
              __pyx_t_29 += __pyx_pybuffernd_ranks.diminfo[0].shape;
              if (unlikely(__pyx_t_29 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_30 < 0) {
              __pyx_t_30 += __pyx_pybuffernd_ranks.diminfo[1].shape;
              if (unlikely(__pyx_t_30 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_ranks.diminfo[1].strides) = __pyx_v_6pandas_5algos_nan;

     592:                 infs += 1

            /* "pandas/algos.pyx":592
     *             if val is nan_value and keep_na:
     *                 ranks[i, argsorted[i, j]] = nan
     *                 infs += 1             # <<<<<<<<<<<<<<
     *                 continue
     *             sum_ranks += (j - infs) + 1
     */
            __pyx_v_infs = (__pyx_v_infs + 1);

     593:                 continue

            /* "pandas/algos.pyx":593
     *                 ranks[i, argsorted[i, j]] = nan
     *                 infs += 1
     *                 continue             # <<<<<<<<<<<<<<
     *             sum_ranks += (j - infs) + 1
     *             dups += 1
     */
            goto __pyx_L24_continue;
          }

     594:             sum_ranks += (j - infs) + 1

          /* "pandas/algos.pyx":594
     *                 infs += 1
     *                 continue
     *             sum_ranks += (j - infs) + 1             # <<<<<<<<<<<<<<
     *             dups += 1
     *             if j == k - 1 or are_diff(values[i, j + 1], val):
     */
          __pyx_v_sum_ranks = (__pyx_v_sum_ranks + ((__pyx_v_j - __pyx_v_infs) + 1));

     595:             dups += 1

          /* "pandas/algos.pyx":595
     *                 continue
     *             sum_ranks += (j - infs) + 1
     *             dups += 1             # <<<<<<<<<<<<<<
     *             if j == k - 1 or are_diff(values[i, j + 1], val):
     *                 if tiebreak == TIEBREAK_AVERAGE:
     */
          __pyx_v_dups = (__pyx_v_dups + 1);

     596:             if j == k - 1 or are_diff(values[i, j + 1], val):

          /* "pandas/algos.pyx":596
     *             sum_ranks += (j - infs) + 1
     *             dups += 1
     *             if j == k - 1 or are_diff(values[i, j + 1], val):             # <<<<<<<<<<<<<<
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):
     */
          __pyx_t_4 = (__pyx_v_j == (__pyx_v_k - 1));
          if (!__pyx_t_4) {
            __pyx_t_31 = __pyx_v_i;
            __pyx_t_32 = (__pyx_v_j + 1);
            __pyx_t_3 = -1;
            if (__pyx_t_31 < 0) {
              __pyx_t_31 += __pyx_pybuffernd_values.diminfo[0].shape;
              if (unlikely(__pyx_t_31 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_3 = 0;
            if (__pyx_t_32 < 0) {
              __pyx_t_32 += __pyx_pybuffernd_values.diminfo[1].shape;
              if (unlikely(__pyx_t_32 < 0)) __pyx_t_3 = 1;
            } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_values.diminfo[1].shape)) __pyx_t_3 = 1;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_1 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_values.diminfo[1].strides);
            __Pyx_INCREF((PyObject*)__pyx_t_1);
            __pyx_t_2 = __pyx_f_6pandas_5algos_are_diff(__pyx_t_1, __pyx_v_val); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_21 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_21 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_33 = __pyx_t_21;
          } else {
            __pyx_t_33 = __pyx_t_4;
          }
          if (__pyx_t_33) {

     597:                 if tiebreak == TIEBREAK_AVERAGE:

            /* "pandas/algos.pyx":597
     *             dups += 1
     *             if j == k - 1 or are_diff(values[i, j + 1], val):
     *                 if tiebreak == TIEBREAK_AVERAGE:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     */
            __pyx_t_33 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_AVERAGE) != 0);
            if (__pyx_t_33) {

     598:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":598
     *             if j == k - 1 or are_diff(values[i, j + 1], val):
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:
     */
              __pyx_t_34 = (__pyx_v_j + 1);
              for (__pyx_t_35 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_35 < __pyx_t_34; __pyx_t_35+=1) {
                __pyx_v_z = __pyx_t_35;

     599:                         ranks[i, argsorted[i, z]] = sum_ranks / dups

                /* "pandas/algos.pyx":599
     *                 if tiebreak == TIEBREAK_AVERAGE:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):
     */
                if (unlikely(__pyx_v_dups == 0)) {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                  #endif
                  PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                  #ifdef WITH_THREAD
                  PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_36 = __pyx_v_i;
                __pyx_t_37 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_36 < 0) {
                  __pyx_t_36 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_36 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_36 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_37 < 0) {
                  __pyx_t_37 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_37 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_38 = __pyx_v_i;
                __pyx_t_39 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_38 < 0) {
                  __pyx_t_38 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_38 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_38 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_39 < 0) {
                  __pyx_t_39 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_39 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_sum_ranks / __pyx_v_dups);
              }
              goto __pyx_L28;
            }

     600:                 elif tiebreak == TIEBREAK_MIN:

            /* "pandas/algos.pyx":600
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     */
            __pyx_t_33 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MIN) != 0);
            if (__pyx_t_33) {

     601:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":601
     *                         ranks[i, argsorted[i, z]] = sum_ranks / dups
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:
     */
              __pyx_t_34 = (__pyx_v_j + 1);
              for (__pyx_t_35 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_35 < __pyx_t_34; __pyx_t_35+=1) {
                __pyx_v_z = __pyx_t_35;

     602:                         ranks[i, argsorted[i, z]] = j - dups + 2

                /* "pandas/algos.pyx":602
     *                 elif tiebreak == TIEBREAK_MIN:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):
     */
                __pyx_t_40 = __pyx_v_i;
                __pyx_t_41 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_40 < 0) {
                  __pyx_t_40 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_40 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_40 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_41 < 0) {
                  __pyx_t_41 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_41 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_41 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_42 = __pyx_v_i;
                __pyx_t_43 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_42 < 0) {
                  __pyx_t_42 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_42 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_42 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_43 < 0) {
                  __pyx_t_43 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_43 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_43 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_ranks.diminfo[1].strides) = ((__pyx_v_j - __pyx_v_dups) + 2);
              }
              goto __pyx_L28;
            }

     603:                 elif tiebreak == TIEBREAK_MAX:

            /* "pandas/algos.pyx":603
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:             # <<<<<<<<<<<<<<
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1
     */
            __pyx_t_33 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_MAX) != 0);
            if (__pyx_t_33) {

     604:                     for z in range(j - dups + 1, j + 1):

              /* "pandas/algos.pyx":604
     *                         ranks[i, argsorted[i, z]] = j - dups + 2
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):             # <<<<<<<<<<<<<<
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     */
              __pyx_t_34 = (__pyx_v_j + 1);
              for (__pyx_t_35 = ((__pyx_v_j - __pyx_v_dups) + 1); __pyx_t_35 < __pyx_t_34; __pyx_t_35+=1) {
                __pyx_v_z = __pyx_t_35;

     605:                         ranks[i, argsorted[i, z]] = j + 1

                /* "pandas/algos.pyx":605
     *                 elif tiebreak == TIEBREAK_MAX:
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1             # <<<<<<<<<<<<<<
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     raise ValueError('first not supported for '
     */
                __pyx_t_44 = __pyx_v_i;
                __pyx_t_45 = __pyx_v_z;
                __pyx_t_3 = -1;
                if (__pyx_t_44 < 0) {
                  __pyx_t_44 += __pyx_pybuffernd_argsorted.diminfo[0].shape;
                  if (unlikely(__pyx_t_44 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_44 >= __pyx_pybuffernd_argsorted.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_45 < 0) {
                  __pyx_t_45 += __pyx_pybuffernd_argsorted.diminfo[1].shape;
                  if (unlikely(__pyx_t_45 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_45 >= __pyx_pybuffernd_argsorted.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_46 = __pyx_v_i;
                __pyx_t_47 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_argsorted.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_argsorted.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_argsorted.diminfo[1].strides));
                __pyx_t_3 = -1;
                if (__pyx_t_46 < 0) {
                  __pyx_t_46 += __pyx_pybuffernd_ranks.diminfo[0].shape;
                  if (unlikely(__pyx_t_46 < 0)) __pyx_t_3 = 0;
                } else if (unlikely(__pyx_t_46 >= __pyx_pybuffernd_ranks.diminfo[0].shape)) __pyx_t_3 = 0;
                if (__pyx_t_47 < 0) {
                  __pyx_t_47 += __pyx_pybuffernd_ranks.diminfo[1].shape;
                  if (unlikely(__pyx_t_47 < 0)) __pyx_t_3 = 1;
                } else if (unlikely(__pyx_t_47 >= __pyx_pybuffernd_ranks.diminfo[1].shape)) __pyx_t_3 = 1;
                if (unlikely(__pyx_t_3 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_3);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ranks.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_ranks.diminfo[0].strides, __pyx_t_47, __pyx_pybuffernd_ranks.diminfo[1].strides) = (__pyx_v_j + 1);
              }
              goto __pyx_L28;
            }

     606:                 elif tiebreak == TIEBREAK_FIRST:

            /* "pandas/algos.pyx":606
     *                     for z in range(j - dups + 1, j + 1):
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:             # <<<<<<<<<<<<<<
     *                     raise ValueError('first not supported for '
     *                                      'non-numeric data')
     */
            __pyx_t_33 = ((__pyx_v_tiebreak == __pyx_v_6pandas_5algos_TIEBREAK_FIRST) != 0);
            if (__pyx_t_33) {

     607:                     raise ValueError('first not supported for '

              /* "pandas/algos.pyx":607
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     raise ValueError('first not supported for '             # <<<<<<<<<<<<<<
     *                                      'non-numeric data')
     *                 sum_ranks = dups = 0
     */
              __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_Raise(__pyx_t_2, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_L28:;

      /* "pandas/algos.pyx":607
     *                         ranks[i, argsorted[i, z]] = j + 1
     *                 elif tiebreak == TIEBREAK_FIRST:
     *                     raise ValueError('first not supported for '             # <<<<<<<<<<<<<<
     *                                      'non-numeric data')
     *                 sum_ranks = dups = 0
     */
      __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_first_not_supported_for_non_nume); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__26);
      __Pyx_GIVEREF(__pyx_tuple__26);

     608:                                      'non-numeric data')

     609:                 sum_ranks = dups = 0

            /* "pandas/algos.pyx":609
     *                     raise ValueError('first not supported for '
     *                                      'non-numeric data')
     *                 sum_ranks = dups = 0             # <<<<<<<<<<<<<<
     *
     *     if axis == 0:
     */
            __pyx_v_sum_ranks = 0;
            __pyx_v_dups = 0;
            goto __pyx_L27;
          }
          __pyx_L27:;
          __pyx_L24_continue:;
        }
      }

     610:

     611:     if axis == 0:

      /* "pandas/algos.pyx":611
     *                 sum_ranks = dups = 0
     *
     *     if axis == 0:             # <<<<<<<<<<<<<<
     *         return ranks.T
     *     else:
     */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_33 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_33) {

     612:         return ranks.T

        /* "pandas/algos.pyx":612
     *
     *     if axis == 0:
     *         return ranks.T             # <<<<<<<<<<<<<<
     *     else:
     *         return ranks
     */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ranks), __pyx_n_s_T); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L0;
      }
      /*else*/ {

     613:     else:

     614:         return ranks

        /* "pandas/algos.pyx":614
     *         return ranks.T
     *     else:
     *         return ranks             # <<<<<<<<<<<<<<
     *
     * # def _take_indexer_2d(ndarray[float64_t, ndim=2] values,
     */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(((PyObject *)__pyx_v_ranks));
        __pyx_r = ((PyObject *)__pyx_v_ranks);
        goto __pyx_L0;
      }

     615:

     616: # def _take_indexer_2d(ndarray[float64_t, ndim=2] values,

     617: #                      ndarray[Py_ssize_t, ndim=2, cast=True] indexer):

     618: #     cdef:

     619: #         Py_ssize_t i, j, N, K

     620: #         ndarray[float64_t, ndim=2] result

     621:

     622: #     N, K = (<object> values).shape

     623: #     result = np.empty_like(values)

     624: #     for i in range(N):

     625: #         for j in range(K):

     626: #             result[i, j] = values[i, indexer[i, j]]

     627: #     return result

     628:

     629:

     630: # Cython implementations of rolling sum, mean, variance, skewness,

     631: # other statistical moment functions

     632: #

     633: # Misc implementation notes

     634: # -------------------------

     635: #

     636: # - In Cython x * x is faster than x ** 2 for C types, this should be

     637: #   periodically revisited to see if it's still true.

     638: #

     639: # -

     640:

     641: def _check_minp(win, minp, N):

    /* "pandas/algos.pyx":641
     * # -
     *
     * def _check_minp(win, minp, N):             # <<<<<<<<<<<<<<
     *     if minp > win:
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_13_check_minp(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_13_check_minp = {__Pyx_NAMESTR("_check_minp"), (PyCFunction)__pyx_pw_6pandas_5algos_13_check_minp, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_13_check_minp(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_win = 0;
      PyObject *__pyx_v_minp = 0;
      PyObject *__pyx_v_N = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_check_minp (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_win,&__pyx_n_s_minp,&__pyx_n_s_N,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_check_minp", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_N)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_check_minp", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_check_minp") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_win = values[0];
        __pyx_v_minp = values[1];
        __pyx_v_N = values[2];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_check_minp", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos._check_minp", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6pandas_5algos_12_check_minp(__pyx_self, __pyx_v_win, __pyx_v_minp, __pyx_v_N);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_12_check_minp(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_win, PyObject *__pyx_v_minp, PyObject *__pyx_v_N) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_check_minp", 0);
      __Pyx_INCREF(__pyx_v_minp);

      /* "pandas/algos.pyx":641
     * # -
     *
     * def _check_minp(win, minp, N):             # <<<<<<<<<<<<<<
     *     if minp > win:
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_AddTraceback("pandas.algos._check_minp", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_minp);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":641
     * # -
     *
     * def _check_minp(win, minp, N):             # <<<<<<<<<<<<<<
     *     if minp > win:
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     */
      __pyx_tuple__228 = PyTuple_Pack(3, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_N); if (unlikely(!__pyx_tuple__228)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__228);
      __Pyx_GIVEREF(__pyx_tuple__228);

      /* "pandas/algos.pyx":641
     * # -
     *
     * def _check_minp(win, minp, N):             # <<<<<<<<<<<<<<
     *     if minp > win:
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_13_check_minp, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_minp, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__229 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__228, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_check_minp, 641, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__229)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     642:     if minp > win:

      /* "pandas/algos.pyx":642
     *
     * def _check_minp(win, minp, N):
     *     if minp > win:             # <<<<<<<<<<<<<<
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     *                         % (minp, win))
     */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_minp, __pyx_v_win, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_2) {

     643:         raise ValueError('min_periods (%d) must be <= window (%d)'

        /* "pandas/algos.pyx":643
     * def _check_minp(win, minp, N):
     *     if minp > win:
     *         raise ValueError('min_periods (%d) must be <= window (%d)'             # <<<<<<<<<<<<<<
     *                         % (minp, win))
     *     elif minp > N:
     */
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

     644:                         % (minp, win))

        /* "pandas/algos.pyx":644
     *     if minp > win:
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     *                         % (minp, win))             # <<<<<<<<<<<<<<
     *     elif minp > N:
     *         minp = N + 1
     */
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_minp);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_minp);
        __Pyx_GIVEREF(__pyx_v_minp);
        __Pyx_INCREF(__pyx_v_win);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_win);
        __Pyx_GIVEREF(__pyx_v_win);
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_min_periods_d_must_be_window_d, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     645:     elif minp > N:

      /* "pandas/algos.pyx":645
     *         raise ValueError('min_periods (%d) must be <= window (%d)'
     *                         % (minp, win))
     *     elif minp > N:             # <<<<<<<<<<<<<<
     *         minp = N + 1
     *     elif minp == 0:
     */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_minp, __pyx_v_N, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_2) {

     646:         minp = N + 1

        /* "pandas/algos.pyx":646
     *                         % (minp, win))
     *     elif minp > N:
     *         minp = N + 1             # <<<<<<<<<<<<<<
     *     elif minp == 0:
     *         minp = 1
     */
        __pyx_t_3 = PyNumber_Add(__pyx_v_N, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF_SET(__pyx_v_minp, __pyx_t_3);
        __pyx_t_3 = 0;
        goto __pyx_L3;
      }

     647:     elif minp == 0:

      /* "pandas/algos.pyx":647
     *     elif minp > N:
     *         minp = N + 1
     *     elif minp == 0:             # <<<<<<<<<<<<<<
     *         minp = 1
     *     elif minp < 0:
     */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_minp, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_2) {

     648:         minp = 1

        /* "pandas/algos.pyx":648
     *         minp = N + 1
     *     elif minp == 0:
     *         minp = 1             # <<<<<<<<<<<<<<
     *     elif minp < 0:
     *         raise ValueError('min_periods must be >= 0')
     */
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_DECREF_SET(__pyx_v_minp, __pyx_int_1);
        goto __pyx_L3;
      }

     649:     elif minp < 0:

      /* "pandas/algos.pyx":649
     *     elif minp == 0:
     *         minp = 1
     *     elif minp < 0:             # <<<<<<<<<<<<<<
     *         raise ValueError('min_periods must be >= 0')
     *     return minp
     */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_minp, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_2) {

     650:         raise ValueError('min_periods must be >= 0')

        /* "pandas/algos.pyx":650
     *         minp = 1
     *     elif minp < 0:
     *         raise ValueError('min_periods must be >= 0')             # <<<<<<<<<<<<<<
     *     return minp
     *
     */
        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L3:;

      /* "pandas/algos.pyx":650
     *         minp = 1
     *     elif minp < 0:
     *         raise ValueError('min_periods must be >= 0')             # <<<<<<<<<<<<<<
     *     return minp
     *
     */
      __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_min_periods_must_be_0); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__27);
      __Pyx_GIVEREF(__pyx_tuple__27);

     651:     return minp

      /* "pandas/algos.pyx":651
     *     elif minp < 0:
     *         raise ValueError('min_periods must be >= 0')
     *     return minp             # <<<<<<<<<<<<<<
     *
     * # original C implementation by N. Devillard.
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_minp);
      __pyx_r = __pyx_v_minp;
      goto __pyx_L0;

     652:

     653: # original C implementation by N. Devillard.

     654: # This code in public domain.

     655: # Function :   kth_smallest()

     656: # In       :   array of elements, # of elements in the array, rank k

     657: # Out      :   one element

     658: # Job      :   find the kth smallest element in the array

     659:

     660: #             Reference:

     661:

     662: #               Author: Wirth, Niklaus

     663: #                Title: Algorithms + data structures = programs

     664: #            Publisher: Englewood Cliffs: Prentice-Hall, 1976

     665: # Physical description: 366 p.

     666: #               Series: Prentice-Hall Series in Automatic Computation

     667:

     668: def kth_smallest(ndarray[double_t] a, Py_ssize_t k):

    /* "pandas/algos.pyx":668
     * #               Series: Prentice-Hall Series in Automatic Computation
     *
     * def kth_smallest(ndarray[double_t] a, Py_ssize_t k):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i,j,l,m,n
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_15kth_smallest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_15kth_smallest = {__Pyx_NAMESTR("kth_smallest"), (PyCFunction)__pyx_pw_6pandas_5algos_15kth_smallest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_15kth_smallest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_a = 0;
      Py_ssize_t __pyx_v_k;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("kth_smallest (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_k,0};
        PyObject* values[2] = {0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("kth_smallest", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "kth_smallest") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        }
        __pyx_v_a = ((PyArrayObject *)values[0]);
        __pyx_v_k = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_k == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("kth_smallest", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.kth_smallest", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_14kth_smallest(__pyx_self, __pyx_v_a, __pyx_v_k);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_14kth_smallest(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_a, Py_ssize_t __pyx_v_k) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_l;
      Py_ssize_t __pyx_v_m;
      Py_ssize_t __pyx_v_n;
      __pyx_t_5numpy_double_t __pyx_v_x;
      __pyx_t_5numpy_double_t __pyx_v_t;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_a;
      __Pyx_Buffer __pyx_pybuffer_a;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("kth_smallest", 0);
      __pyx_pybuffer_a.pybuffer.buf = NULL;
      __pyx_pybuffer_a.refcount = 0;
      __pyx_pybuffernd_a.data = NULL;
      __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":668
     * #               Series: Prentice-Hall Series in Automatic Computation
     *
     * def kth_smallest(ndarray[double_t] a, Py_ssize_t k):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i,j,l,m,n
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_11);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.kth_smallest", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":668
     * #               Series: Prentice-Hall Series in Automatic Computation
     *
     * def kth_smallest(ndarray[double_t] a, Py_ssize_t k):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i,j,l,m,n
     */
      __pyx_tuple__230 = PyTuple_Pack(9, __pyx_n_s_a, __pyx_n_s_k, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_l, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_x, __pyx_n_s_t); if (unlikely(!__pyx_tuple__230)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__230);
      __Pyx_GIVEREF(__pyx_tuple__230);

      /* "pandas/algos.pyx":668
     * #               Series: Prentice-Hall Series in Automatic Computation
     *
     * def kth_smallest(ndarray[double_t] a, Py_ssize_t k):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i,j,l,m,n
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_15kth_smallest, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_kth_smallest, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__231 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__230, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_kth_smallest, 668, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__231)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     669:     cdef:

     670:         Py_ssize_t i,j,l,m,n

     671:         double_t x, t

     672:

     673:     n = len(a)

      /* "pandas/algos.pyx":673
     *         double_t x, t
     *
     *     n = len(a)             # <<<<<<<<<<<<<<
     *
     *     l = 0
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_1;

     674:

     675:     l = 0

      /* "pandas/algos.pyx":675
     *     n = len(a)
     *
     *     l = 0             # <<<<<<<<<<<<<<
     *     m = n-1
     *     while (l<m):
     */
      __pyx_v_l = 0;

     676:     m = n-1

      /* "pandas/algos.pyx":676
     *
     *     l = 0
     *     m = n-1             # <<<<<<<<<<<<<<
     *     while (l<m):
     *         x = a[k]
     */
      __pyx_v_m = (__pyx_v_n - 1);

     677:     while (l<m):

      /* "pandas/algos.pyx":677
     *     l = 0
     *     m = n-1
     *     while (l<m):             # <<<<<<<<<<<<<<
     *         x = a[k]
     *         i = l
     */
      while (1) {
        __pyx_t_2 = ((__pyx_v_l < __pyx_v_m) != 0);
        if (!__pyx_t_2) break;

     678:         x = a[k]

        /* "pandas/algos.pyx":678
     *     m = n-1
     *     while (l<m):
     *         x = a[k]             # <<<<<<<<<<<<<<
     *         i = l
     *         j = m
     */
        __pyx_t_1 = __pyx_v_k;
        __pyx_t_3 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_a.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
        if (unlikely(__pyx_t_3 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_3);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_x = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_a.diminfo[0].strides));

     679:         i = l

        /* "pandas/algos.pyx":679
     *     while (l<m):
     *         x = a[k]
     *         i = l             # <<<<<<<<<<<<<<
     *         j = m
     *
     */
        __pyx_v_i = __pyx_v_l;

     680:         j = m

        /* "pandas/algos.pyx":680
     *         x = a[k]
     *         i = l
     *         j = m             # <<<<<<<<<<<<<<
     *
     *         while 1:
     */
        __pyx_v_j = __pyx_v_m;

     681:

     682:         while 1:

        /* "pandas/algos.pyx":682
     *         j = m
     *
     *         while 1:             # <<<<<<<<<<<<<<
     *             while a[i] < x: i += 1
     *             while x < a[j]: j -= 1
     */
        while (1) {

     683:             while a[i] < x: i += 1

          /* "pandas/algos.pyx":683
     *
     *         while 1:
     *             while a[i] < x: i += 1             # <<<<<<<<<<<<<<
     *             while x < a[j]: j -= 1
     *             if i <= j:
     */
          while (1) {
            __pyx_t_4 = __pyx_v_i;
            __pyx_t_3 = -1;
            if (__pyx_t_4 < 0) {
              __pyx_t_4 += __pyx_pybuffernd_a.diminfo[0].shape;
              if (unlikely(__pyx_t_4 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_2 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_a.diminfo[0].strides)) < __pyx_v_x) != 0);
            if (!__pyx_t_2) break;
            __pyx_v_i = (__pyx_v_i + 1);
          }

     684:             while x < a[j]: j -= 1

          /* "pandas/algos.pyx":684
     *         while 1:
     *             while a[i] < x: i += 1
     *             while x < a[j]: j -= 1             # <<<<<<<<<<<<<<
     *             if i <= j:
     *                 t = a[i]
     */
          while (1) {
            __pyx_t_5 = __pyx_v_j;
            __pyx_t_3 = -1;
            if (__pyx_t_5 < 0) {
              __pyx_t_5 += __pyx_pybuffernd_a.diminfo[0].shape;
              if (unlikely(__pyx_t_5 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_2 = ((__pyx_v_x < (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_a.diminfo[0].strides))) != 0);
            if (!__pyx_t_2) break;
            __pyx_v_j = (__pyx_v_j - 1);
          }

     685:             if i <= j:

          /* "pandas/algos.pyx":685
     *             while a[i] < x: i += 1
     *             while x < a[j]: j -= 1
     *             if i <= j:             # <<<<<<<<<<<<<<
     *                 t = a[i]
     *                 a[i] = a[j]
     */
          __pyx_t_2 = ((__pyx_v_i <= __pyx_v_j) != 0);
          if (__pyx_t_2) {

     686:                 t = a[i]

            /* "pandas/algos.pyx":686
     *             while x < a[j]: j -= 1
     *             if i <= j:
     *                 t = a[i]             # <<<<<<<<<<<<<<
     *                 a[i] = a[j]
     *                 a[j] = t
     */
            __pyx_t_6 = __pyx_v_i;
            __pyx_t_3 = -1;
            if (__pyx_t_6 < 0) {
              __pyx_t_6 += __pyx_pybuffernd_a.diminfo[0].shape;
              if (unlikely(__pyx_t_6 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_t = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_a.diminfo[0].strides));

     687:                 a[i] = a[j]

            /* "pandas/algos.pyx":687
     *             if i <= j:
     *                 t = a[i]
     *                 a[i] = a[j]             # <<<<<<<<<<<<<<
     *                 a[j] = t
     *                 i += 1; j -= 1
     */
            __pyx_t_7 = __pyx_v_j;
            __pyx_t_3 = -1;
            if (__pyx_t_7 < 0) {
              __pyx_t_7 += __pyx_pybuffernd_a.diminfo[0].shape;
              if (unlikely(__pyx_t_7 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_8 = __pyx_v_i;
            __pyx_t_3 = -1;
            if (__pyx_t_8 < 0) {
              __pyx_t_8 += __pyx_pybuffernd_a.diminfo[0].shape;
              if (unlikely(__pyx_t_8 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_a.diminfo[0].strides) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_a.diminfo[0].strides));

     688:                 a[j] = t

            /* "pandas/algos.pyx":688
     *                 t = a[i]
     *                 a[i] = a[j]
     *                 a[j] = t             # <<<<<<<<<<<<<<
     *                 i += 1; j -= 1
     *
     */
            __pyx_t_9 = __pyx_v_j;
            __pyx_t_3 = -1;
            if (__pyx_t_9 < 0) {
              __pyx_t_9 += __pyx_pybuffernd_a.diminfo[0].shape;
              if (unlikely(__pyx_t_9 < 0)) __pyx_t_3 = 0;
            } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
            if (unlikely(__pyx_t_3 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_3);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_a.diminfo[0].strides) = __pyx_v_t;

     689:                 i += 1; j -= 1

            /* "pandas/algos.pyx":689
     *                 a[i] = a[j]
     *                 a[j] = t
     *                 i += 1; j -= 1             # <<<<<<<<<<<<<<
     *
     *             if i > j: break
     */
            __pyx_v_i = (__pyx_v_i + 1);
            __pyx_v_j = (__pyx_v_j - 1);
            goto __pyx_L11;
          }
          __pyx_L11:;

     690:

     691:             if i > j: break

          /* "pandas/algos.pyx":691
     *                 i += 1; j -= 1
     *
     *             if i > j: break             # <<<<<<<<<<<<<<
     *
     *         if j < k: l = i
     */
          __pyx_t_2 = ((__pyx_v_i > __pyx_v_j) != 0);
          if (__pyx_t_2) {
            goto __pyx_L6_break;
          }
        }
        __pyx_L6_break:;

     692:

     693:         if j < k: l = i

        /* "pandas/algos.pyx":693
     *             if i > j: break
     *
     *         if j < k: l = i             # <<<<<<<<<<<<<<
     *         if k < i: m = j
     *     return a[k]
     */
        __pyx_t_2 = ((__pyx_v_j < __pyx_v_k) != 0);
        if (__pyx_t_2) {
          __pyx_v_l = __pyx_v_i;
          goto __pyx_L13;
        }
        __pyx_L13:;

     694:         if k < i: m = j

        /* "pandas/algos.pyx":694
     *
     *         if j < k: l = i
     *         if k < i: m = j             # <<<<<<<<<<<<<<
     *     return a[k]
     *
     */
        __pyx_t_2 = ((__pyx_v_k < __pyx_v_i) != 0);
        if (__pyx_t_2) {
          __pyx_v_m = __pyx_v_j;
          goto __pyx_L14;
        }
        __pyx_L14:;
      }

     695:     return a[k]

      /* "pandas/algos.pyx":695
     *         if j < k: l = i
     *         if k < i: m = j
     *     return a[k]             # <<<<<<<<<<<<<<
     *
     * cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n):
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_10 = __pyx_v_k;
      __pyx_t_3 = -1;
      if (__pyx_t_10 < 0) {
        __pyx_t_10 += __pyx_pybuffernd_a.diminfo[0].shape;
        if (unlikely(__pyx_t_10 < 0)) __pyx_t_3 = 0;
      } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_3 = 0;
      if (unlikely(__pyx_t_3 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_3);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_a.diminfo[0].strides))); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_r = __pyx_t_11;
      __pyx_t_11 = 0;
      goto __pyx_L0;

     696:

     697: cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n):

    /* "pandas/algos.pyx":697
     *     return a[k]
     *
     * cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i,j,l,m
     */

    static CYTHON_INLINE PyObject *__pyx_f_6pandas_5algos_kth_smallest_c(__pyx_t_5numpy_float64_t *__pyx_v_a, Py_ssize_t __pyx_v_k, Py_ssize_t __pyx_v_n) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_l;
      Py_ssize_t __pyx_v_m;
      __pyx_t_5numpy_double_t __pyx_v_x;
      __pyx_t_5numpy_double_t __pyx_v_t;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("kth_smallest_c", 0);

      /* "pandas/algos.pyx":697
     *     return a[k]
     *
     * cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i,j,l,m
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("pandas.algos.kth_smallest_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     698:     cdef:

     699:         Py_ssize_t i,j,l,m

     700:         double_t x, t

     701:

     702:     l = 0

      /* "pandas/algos.pyx":702
     *         double_t x, t
     *
     *     l = 0             # <<<<<<<<<<<<<<
     *     m = n-1
     *     while (l<m):
     */
      __pyx_v_l = 0;

     703:     m = n-1

      /* "pandas/algos.pyx":703
     *
     *     l = 0
     *     m = n-1             # <<<<<<<<<<<<<<
     *     while (l<m):
     *         x = a[k]
     */
      __pyx_v_m = (__pyx_v_n - 1);

     704:     while (l<m):

      /* "pandas/algos.pyx":704
     *     l = 0
     *     m = n-1
     *     while (l<m):             # <<<<<<<<<<<<<<
     *         x = a[k]
     *         i = l
     */
      while (1) {
        __pyx_t_1 = ((__pyx_v_l < __pyx_v_m) != 0);
        if (!__pyx_t_1) break;

     705:         x = a[k]

        /* "pandas/algos.pyx":705
     *     m = n-1
     *     while (l<m):
     *         x = a[k]             # <<<<<<<<<<<<<<
     *         i = l
     *         j = m
     */
        __pyx_v_x = (__pyx_v_a[__pyx_v_k]);

     706:         i = l

        /* "pandas/algos.pyx":706
     *     while (l<m):
     *         x = a[k]
     *         i = l             # <<<<<<<<<<<<<<
     *         j = m
     *
     */
        __pyx_v_i = __pyx_v_l;

     707:         j = m

        /* "pandas/algos.pyx":707
     *         x = a[k]
     *         i = l
     *         j = m             # <<<<<<<<<<<<<<
     *
     *         while 1:
     */
        __pyx_v_j = __pyx_v_m;

     708:

     709:         while 1:

        /* "pandas/algos.pyx":709
     *         j = m
     *
     *         while 1:             # <<<<<<<<<<<<<<
     *             while a[i] < x: i += 1
     *             while x < a[j]: j -= 1
     */
        while (1) {

     710:             while a[i] < x: i += 1

          /* "pandas/algos.pyx":710
     *
     *         while 1:
     *             while a[i] < x: i += 1             # <<<<<<<<<<<<<<
     *             while x < a[j]: j -= 1
     *             if i <= j:
     */
          while (1) {
            __pyx_t_1 = (((__pyx_v_a[__pyx_v_i]) < __pyx_v_x) != 0);
            if (!__pyx_t_1) break;
            __pyx_v_i = (__pyx_v_i + 1);
          }

     711:             while x < a[j]: j -= 1

          /* "pandas/algos.pyx":711
     *         while 1:
     *             while a[i] < x: i += 1
     *             while x < a[j]: j -= 1             # <<<<<<<<<<<<<<
     *             if i <= j:
     *                 t = a[i]
     */
          while (1) {
            __pyx_t_1 = ((__pyx_v_x < (__pyx_v_a[__pyx_v_j])) != 0);
            if (!__pyx_t_1) break;
            __pyx_v_j = (__pyx_v_j - 1);
          }

     712:             if i <= j:

          /* "pandas/algos.pyx":712
     *             while a[i] < x: i += 1
     *             while x < a[j]: j -= 1
     *             if i <= j:             # <<<<<<<<<<<<<<
     *                 t = a[i]
     *                 a[i] = a[j]
     */
          __pyx_t_1 = ((__pyx_v_i <= __pyx_v_j) != 0);
          if (__pyx_t_1) {

     713:                 t = a[i]

            /* "pandas/algos.pyx":713
     *             while x < a[j]: j -= 1
     *             if i <= j:
     *                 t = a[i]             # <<<<<<<<<<<<<<
     *                 a[i] = a[j]
     *                 a[j] = t
     */
            __pyx_v_t = (__pyx_v_a[__pyx_v_i]);

     714:                 a[i] = a[j]

            /* "pandas/algos.pyx":714
     *             if i <= j:
     *                 t = a[i]
     *                 a[i] = a[j]             # <<<<<<<<<<<<<<
     *                 a[j] = t
     *                 i += 1; j -= 1
     */
            (__pyx_v_a[__pyx_v_i]) = (__pyx_v_a[__pyx_v_j]);

     715:                 a[j] = t

            /* "pandas/algos.pyx":715
     *                 t = a[i]
     *                 a[i] = a[j]
     *                 a[j] = t             # <<<<<<<<<<<<<<
     *                 i += 1; j -= 1
     *
     */
            (__pyx_v_a[__pyx_v_j]) = __pyx_v_t;

     716:                 i += 1; j -= 1

            /* "pandas/algos.pyx":716
     *                 a[i] = a[j]
     *                 a[j] = t
     *                 i += 1; j -= 1             # <<<<<<<<<<<<<<
     *
     *             if i > j: break
     */
            __pyx_v_i = (__pyx_v_i + 1);
            __pyx_v_j = (__pyx_v_j - 1);
            goto __pyx_L11;
          }
          __pyx_L11:;

     717:

     718:             if i > j: break

          /* "pandas/algos.pyx":718
     *                 i += 1; j -= 1
     *
     *             if i > j: break             # <<<<<<<<<<<<<<
     *
     *         if j < k: l = i
     */
          __pyx_t_1 = ((__pyx_v_i > __pyx_v_j) != 0);
          if (__pyx_t_1) {
            goto __pyx_L6_break;
          }
        }
        __pyx_L6_break:;

     719:

     720:         if j < k: l = i

        /* "pandas/algos.pyx":720
     *             if i > j: break
     *
     *         if j < k: l = i             # <<<<<<<<<<<<<<
     *         if k < i: m = j
     *     return a[k]
     */
        __pyx_t_1 = ((__pyx_v_j < __pyx_v_k) != 0);
        if (__pyx_t_1) {
          __pyx_v_l = __pyx_v_i;
          goto __pyx_L13;
        }
        __pyx_L13:;

     721:         if k < i: m = j

        /* "pandas/algos.pyx":721
     *
     *         if j < k: l = i
     *         if k < i: m = j             # <<<<<<<<<<<<<<
     *     return a[k]
     *
     */
        __pyx_t_1 = ((__pyx_v_k < __pyx_v_i) != 0);
        if (__pyx_t_1) {
          __pyx_v_m = __pyx_v_j;
          goto __pyx_L14;
        }
        __pyx_L14:;
      }

     722:     return a[k]

      /* "pandas/algos.pyx":722
     *         if j < k: l = i
     *         if k < i: m = j
     *     return a[k]             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyFloat_FromDouble((__pyx_v_a[__pyx_v_k])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

     723:

     724:

     725: def median(ndarray arr):

    /* "pandas/algos.pyx":725
     *
     *
     * def median(ndarray arr):             # <<<<<<<<<<<<<<
     *     '''
     *     A faster median
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_17median(PyObject *__pyx_self, PyObject *__pyx_v_arr); /*proto*/
    static char __pyx_doc_6pandas_5algos_16median[] = "\n    A faster median\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_17median = {__Pyx_NAMESTR("median"), (PyCFunction)__pyx_pw_6pandas_5algos_17median, METH_O, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_16median)};
    static PyObject *__pyx_pw_6pandas_5algos_17median(PyObject *__pyx_self, PyObject *__pyx_v_arr) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("median (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_5numpy_ndarray, 1, "arr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_16median(__pyx_self, ((PyArrayObject *)__pyx_v_arr));
      CYTHON_UNUSED int __pyx_lineno = 0;
      CYTHON_UNUSED const char *__pyx_filename = NULL;
      CYTHON_UNUSED int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_16median(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arr) {
      int __pyx_v_n;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("median", 0);
      __Pyx_INCREF((PyObject *)__pyx_v_arr);

      /* "pandas/algos.pyx":725
     *
     *
     * def median(ndarray arr):             # <<<<<<<<<<<<<<
     *     '''
     *     A faster median
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_AddTraceback("pandas.algos.median", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF((PyObject *)__pyx_v_arr);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":725
     *
     *
     * def median(ndarray arr):             # <<<<<<<<<<<<<<
     *     '''
     *     A faster median
     */
      __pyx_tuple__232 = PyTuple_Pack(2, __pyx_n_s_arr, __pyx_n_s_n); if (unlikely(!__pyx_tuple__232)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__232);
      __Pyx_GIVEREF(__pyx_tuple__232);

      /* "pandas/algos.pyx":725
     *
     *
     * def median(ndarray arr):             # <<<<<<<<<<<<<<
     *     '''
     *     A faster median
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_17median, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_median, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__233 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__232, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_median, 725, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__233)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     726:     '''

     727:     A faster median

     728:     '''

     729:     cdef int n = len(arr)

      /* "pandas/algos.pyx":729
     *     A faster median
     *     '''
     *     cdef int n = len(arr)             # <<<<<<<<<<<<<<
     *
     *     if len(arr) == 0:
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_arr)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_1;

     730:

     731:     if len(arr) == 0:

      /* "pandas/algos.pyx":731
     *     cdef int n = len(arr)
     *
     *     if len(arr) == 0:             # <<<<<<<<<<<<<<
     *         return np.NaN
     *
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_arr)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
      if (__pyx_t_2) {

     732:         return np.NaN

        /* "pandas/algos.pyx":732
     *
     *     if len(arr) == 0:
     *         return np.NaN             # <<<<<<<<<<<<<<
     *
     *     arr = arr.copy()
     */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_NaN); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        goto __pyx_L0;
      }

     733:

     734:     arr = arr.copy()

      /* "pandas/algos.pyx":734
     *         return np.NaN
     *
     *     arr = arr.copy()             # <<<<<<<<<<<<<<
     *
     *     if n % 2:
     */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_arr), __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_arr, ((PyArrayObject *)__pyx_t_3));
      __pyx_t_3 = 0;

     735:

     736:     if n % 2:

      /* "pandas/algos.pyx":736
     *     arr = arr.copy()
     *
     *     if n % 2:             # <<<<<<<<<<<<<<
     *         return kth_smallest(arr, n / 2)
     *     else:
     */
      __pyx_t_2 = (__Pyx_mod_long(__pyx_v_n, 2) != 0);
      if (__pyx_t_2) {

     737:         return kth_smallest(arr, n / 2)

        /* "pandas/algos.pyx":737
     *
     *     if n % 2:
     *         return kth_smallest(arr, n / 2)             # <<<<<<<<<<<<<<
     *     else:
     *         return (kth_smallest(arr, n / 2) +
     */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_kth_smallest); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_n, 2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(((PyObject *)__pyx_v_arr));
        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_arr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_arr));
        PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        goto __pyx_L0;
      }
      /*else*/ {

     738:     else:

     739:         return (kth_smallest(arr, n / 2) +

        /* "pandas/algos.pyx":739
     *         return kth_smallest(arr, n / 2)
     *     else:
     *         return (kth_smallest(arr, n / 2) +             # <<<<<<<<<<<<<<
     *                 kth_smallest(arr, n / 2 - 1)) / 2
     *
     */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_kth_smallest); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_n, 2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(((PyObject *)__pyx_v_arr));
        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_arr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_arr));
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "pandas/algos.pyx":739
     *         return kth_smallest(arr, n / 2)
     *     else:
     *         return (kth_smallest(arr, n / 2) +             # <<<<<<<<<<<<<<
     *                 kth_smallest(arr, n / 2 - 1)) / 2
     *
     */
        __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

     740:                 kth_smallest(arr, n / 2 - 1)) / 2

        /* "pandas/algos.pyx":740
     *     else:
     *         return (kth_smallest(arr, n / 2) +
     *                 kth_smallest(arr, n / 2 - 1)) / 2             # <<<<<<<<<<<<<<
     *
     *
     */
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_kth_smallest); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_long((__Pyx_div_long(__pyx_v_n, 2) - 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(((PyObject *)__pyx_v_arr));
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_arr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_arr));
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "pandas/algos.pyx":740
     *     else:
     *         return (kth_smallest(arr, n / 2) +
     *                 kth_smallest(arr, n / 2 - 1)) / 2             # <<<<<<<<<<<<<<
     *
     *
     */
        __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_int_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        goto __pyx_L0;
      }

     741:

     742:

     743: # -------------- Min, Max subsequence

     744:

     745: def max_subseq(ndarray[double_t] arr):

    /* "pandas/algos.pyx":745
     * # -------------- Min, Max subsequence
     *
     * def max_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i=0,s=0,e=0,T,n
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_19max_subseq(PyObject *__pyx_self, PyObject *__pyx_v_arr); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_19max_subseq = {__Pyx_NAMESTR("max_subseq"), (PyCFunction)__pyx_pw_6pandas_5algos_19max_subseq, METH_O, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_19max_subseq(PyObject *__pyx_self, PyObject *__pyx_v_arr) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("max_subseq (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_5numpy_ndarray, 1, "arr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_18max_subseq(__pyx_self, ((PyArrayObject *)__pyx_v_arr));
      CYTHON_UNUSED int __pyx_lineno = 0;
      CYTHON_UNUSED const char *__pyx_filename = NULL;
      CYTHON_UNUSED int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_18max_subseq(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arr) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_s;
      Py_ssize_t __pyx_v_e;
      Py_ssize_t __pyx_v_T;
      Py_ssize_t __pyx_v_n;
      double __pyx_v_m;
      double __pyx_v_S;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_arr;
      __Pyx_Buffer __pyx_pybuffer_arr;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("max_subseq", 0);
      __pyx_pybuffer_arr.pybuffer.buf = NULL;
      __pyx_pybuffer_arr.refcount = 0;
      __pyx_pybuffernd_arr.data = NULL;
      __pyx_pybuffernd_arr.rcbuffer = &__pyx_pybuffer_arr;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_arr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_arr.diminfo[0].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arr.diminfo[0].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":745
     * # -------------- Min, Max subsequence
     *
     * def max_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i=0,s=0,e=0,T,n
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_t_11);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.max_subseq", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":745
     * # -------------- Min, Max subsequence
     *
     * def max_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i=0,s=0,e=0,T,n
     */
      __pyx_tuple__234 = PyTuple_Pack(8, __pyx_n_s_arr, __pyx_n_s_i, __pyx_n_s_s, __pyx_n_s_e, __pyx_n_s_T, __pyx_n_s_n, __pyx_n_s_m, __pyx_n_s_S); if (unlikely(!__pyx_tuple__234)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__234);
      __Pyx_GIVEREF(__pyx_tuple__234);

      /* "pandas/algos.pyx":745
     * # -------------- Min, Max subsequence
     *
     * def max_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i=0,s=0,e=0,T,n
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_19max_subseq, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_max_subseq, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__235 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__234, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_max_subseq, 745, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__235)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     746:     cdef:

     747:         Py_ssize_t i=0,s=0,e=0,T,n

      /* "pandas/algos.pyx":747
     * def max_subseq(ndarray[double_t] arr):
     *     cdef:
     *         Py_ssize_t i=0,s=0,e=0,T,n             # <<<<<<<<<<<<<<
     *         double m, S
     *
     */
      __pyx_v_i = 0;
      __pyx_v_s = 0;
      __pyx_v_e = 0;

     748:         double m, S

     749:

     750:     n = len(arr)

      /* "pandas/algos.pyx":750
     *         double m, S
     *
     *     n = len(arr)             # <<<<<<<<<<<<<<
     *
     *     if len(arr) == 0:
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_arr)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_1;

     751:

     752:     if len(arr) == 0:

      /* "pandas/algos.pyx":752
     *     n = len(arr)
     *
     *     if len(arr) == 0:             # <<<<<<<<<<<<<<
     *         return (-1,-1,None)
     *
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_arr)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
      if (__pyx_t_2) {

     753:         return (-1,-1,None)

        /* "pandas/algos.pyx":753
     *
     *     if len(arr) == 0:
     *         return (-1,-1,None)             # <<<<<<<<<<<<<<
     *
     *     m = arr[0]
     */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_tuple__28);
        __pyx_r = __pyx_tuple__28;
        goto __pyx_L0;
      }

      /* "pandas/algos.pyx":753
     *
     *     if len(arr) == 0:
     *         return (-1,-1,None)             # <<<<<<<<<<<<<<
     *
     *     m = arr[0]
     */
      __pyx_tuple__28 = PyTuple_Pack(3, __pyx_int_neg_1, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__28);
      __Pyx_GIVEREF(__pyx_tuple__28);

     754:

     755:     m = arr[0]

      /* "pandas/algos.pyx":755
     *         return (-1,-1,None)
     *
     *     m = arr[0]             # <<<<<<<<<<<<<<
     *     S = m
     *     T = 0
     */
      __pyx_t_3 = 0;
      __pyx_t_4 = -1;
      if (__pyx_t_3 < 0) {
        __pyx_t_3 += __pyx_pybuffernd_arr.diminfo[0].shape;
        if (unlikely(__pyx_t_3 < 0)) __pyx_t_4 = 0;
      } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_4 = 0;
      if (unlikely(__pyx_t_4 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_4);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_m = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_arr.diminfo[0].strides));

     756:     S = m

      /* "pandas/algos.pyx":756
     *
     *     m = arr[0]
     *     S = m             # <<<<<<<<<<<<<<
     *     T = 0
     *
     */
      __pyx_v_S = __pyx_v_m;

     757:     T = 0

      /* "pandas/algos.pyx":757
     *     m = arr[0]
     *     S = m
     *     T = 0             # <<<<<<<<<<<<<<
     *
     *     for i in range(1, n):
     */
      __pyx_v_T = 0;

     758:

     759:     for i in range(1, n):

      /* "pandas/algos.pyx":759
     *     T = 0
     *
     *     for i in range(1, n):             # <<<<<<<<<<<<<<
     *         # S = max { S + A[i], A[i] )
     *         if (S > 0):
     */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=1) {
        __pyx_v_i = __pyx_t_5;

     760:         # S = max { S + A[i], A[i] )

     761:         if (S > 0):

        /* "pandas/algos.pyx":761
     *     for i in range(1, n):
     *         # S = max { S + A[i], A[i] )
     *         if (S > 0):             # <<<<<<<<<<<<<<
     *             S = S + arr[i]
     *         else:
     */
        __pyx_t_2 = ((__pyx_v_S > 0.0) != 0);
        if (__pyx_t_2) {

     762:             S = S + arr[i]

          /* "pandas/algos.pyx":762
     *         # S = max { S + A[i], A[i] )
     *         if (S > 0):
     *             S = S + arr[i]             # <<<<<<<<<<<<<<
     *         else:
     *             S = arr[i]
     */
          __pyx_t_6 = __pyx_v_i;
          __pyx_t_4 = -1;
          if (__pyx_t_6 < 0) {
            __pyx_t_6 += __pyx_pybuffernd_arr.diminfo[0].shape;
            if (unlikely(__pyx_t_6 < 0)) __pyx_t_4 = 0;
          } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_4 = 0;
          if (unlikely(__pyx_t_4 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_4);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_S = (__pyx_v_S + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_arr.diminfo[0].strides)));
          goto __pyx_L6;
        }
        /*else*/ {

     763:         else:

     764:             S = arr[i]

          /* "pandas/algos.pyx":764
     *             S = S + arr[i]
     *         else:
     *             S = arr[i]             # <<<<<<<<<<<<<<
     *             T = i
     *         if S > m:
     */
          __pyx_t_7 = __pyx_v_i;
          __pyx_t_4 = -1;
          if (__pyx_t_7 < 0) {
            __pyx_t_7 += __pyx_pybuffernd_arr.diminfo[0].shape;
            if (unlikely(__pyx_t_7 < 0)) __pyx_t_4 = 0;
          } else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_4 = 0;
          if (unlikely(__pyx_t_4 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_4);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_S = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_arr.diminfo[0].strides));

     765:             T = i

          /* "pandas/algos.pyx":765
     *         else:
     *             S = arr[i]
     *             T = i             # <<<<<<<<<<<<<<
     *         if S > m:
     *             s = T
     */
          __pyx_v_T = __pyx_v_i;
        }
        __pyx_L6:;

     766:         if S > m:

        /* "pandas/algos.pyx":766
     *             S = arr[i]
     *             T = i
     *         if S > m:             # <<<<<<<<<<<<<<
     *             s = T
     *             e = i
     */
        __pyx_t_2 = ((__pyx_v_S > __pyx_v_m) != 0);
        if (__pyx_t_2) {

     767:             s = T

          /* "pandas/algos.pyx":767
     *             T = i
     *         if S > m:
     *             s = T             # <<<<<<<<<<<<<<
     *             e = i
     *             m = S
     */
          __pyx_v_s = __pyx_v_T;

     768:             e = i

          /* "pandas/algos.pyx":768
     *         if S > m:
     *             s = T
     *             e = i             # <<<<<<<<<<<<<<
     *             m = S
     *
     */
          __pyx_v_e = __pyx_v_i;

     769:             m = S

          /* "pandas/algos.pyx":769
     *             s = T
     *             e = i
     *             m = S             # <<<<<<<<<<<<<<
     *
     *     return (s, e, m)
     */
          __pyx_v_m = __pyx_v_S;
          goto __pyx_L7;
        }
        __pyx_L7:;
      }

     770:

     771:     return (s, e, m)

      /* "pandas/algos.pyx":771
     *             m = S
     *
     *     return (s, e, m)             # <<<<<<<<<<<<<<
     *
     * def min_subseq(ndarray[double_t] arr):
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_s); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_e); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyFloat_FromDouble(__pyx_v_m); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_t_8 = 0;
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_r = __pyx_t_11;
      __pyx_t_11 = 0;
      goto __pyx_L0;

     772:

     773: def min_subseq(ndarray[double_t] arr):

    /* "pandas/algos.pyx":773
     *     return (s, e, m)
     *
     * def min_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t s, e
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_21min_subseq(PyObject *__pyx_self, PyObject *__pyx_v_arr); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_21min_subseq = {__Pyx_NAMESTR("min_subseq"), (PyCFunction)__pyx_pw_6pandas_5algos_21min_subseq, METH_O, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_21min_subseq(PyObject *__pyx_self, PyObject *__pyx_v_arr) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("min_subseq (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_5numpy_ndarray, 1, "arr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_20min_subseq(__pyx_self, ((PyArrayObject *)__pyx_v_arr));
      CYTHON_UNUSED int __pyx_lineno = 0;
      CYTHON_UNUSED const char *__pyx_filename = NULL;
      CYTHON_UNUSED int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_20min_subseq(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arr) {
      Py_ssize_t __pyx_v_s;
      Py_ssize_t __pyx_v_e;
      double __pyx_v_m;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_arr;
      __Pyx_Buffer __pyx_pybuffer_arr;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("min_subseq", 0);
      __pyx_pybuffer_arr.pybuffer.buf = NULL;
      __pyx_pybuffer_arr.refcount = 0;
      __pyx_pybuffernd_arr.data = NULL;
      __pyx_pybuffernd_arr.rcbuffer = &__pyx_pybuffer_arr;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_arr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_arr.diminfo[0].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arr.diminfo[0].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":773
     *     return (s, e, m)
     *
     * def min_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t s, e
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.min_subseq", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":773
     *     return (s, e, m)
     *
     * def min_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t s, e
     */
      __pyx_tuple__236 = PyTuple_Pack(4, __pyx_n_s_arr, __pyx_n_s_s, __pyx_n_s_e, __pyx_n_s_m); if (unlikely(!__pyx_tuple__236)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__236);
      __Pyx_GIVEREF(__pyx_tuple__236);

      /* "pandas/algos.pyx":773
     *     return (s, e, m)
     *
     * def min_subseq(ndarray[double_t] arr):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t s, e
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_21min_subseq, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_min_subseq, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__237 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__236, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_min_subseq, 773, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__237)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     774:     cdef:

     775:         Py_ssize_t s, e

     776:         double m

     777:

     778:     (s, e, m) = max_subseq(-arr)

      /* "pandas/algos.pyx":778
     *         double m
     *
     *     (s, e, m) = max_subseq(-arr)             # <<<<<<<<<<<<<<
     *
     *     return (s, e, -m)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_max_subseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Negative(((PyObject *)__pyx_v_arr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2);
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1);
          __pyx_t_4 = PyList_GET_ITEM(sequence, 2);
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_s = __pyx_t_7;
      __pyx_v_e = __pyx_t_8;
      __pyx_v_m = __pyx_t_9;

     779:

     780:     return (s, e, -m)

      /* "pandas/algos.pyx":780
     *     (s, e, m) = max_subseq(-arr)
     *
     *     return (s, e, -m)             # <<<<<<<<<<<<<<
     *
     * #-------------------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_e); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyFloat_FromDouble((-__pyx_v_m)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

     781:

     782: #-------------------------------------------------------------------------------

     783: # Rolling sum

     784:

     785: def roll_sum(ndarray[double_t] input, int win, int minp):

    /* "pandas/algos.pyx":785
     * # Rolling sum
     *
     * def roll_sum(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0
     *     cdef int nobs = 0, i
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_23roll_sum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_23roll_sum = {__Pyx_NAMESTR("roll_sum"), (PyCFunction)__pyx_pw_6pandas_5algos_23roll_sum, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_23roll_sum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_sum (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_sum", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_sum", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_sum") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_sum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_22roll_sum(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_22roll_sum(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      double __pyx_v_val;
      double __pyx_v_prev;
      double __pyx_v_sum_x;
      int __pyx_v_nobs;
      int __pyx_v_i;
      int __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_sum", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":785
     * # Rolling sum
     *
     * def roll_sum(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0
     *     cdef int nobs = 0, i
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":785
     * # Rolling sum
     *
     * def roll_sum(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0
     *     cdef int nobs = 0, i
     */
      __pyx_tuple__238 = PyTuple_Pack(10, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_val, __pyx_n_s_prev, __pyx_n_s_sum_x, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output); if (unlikely(!__pyx_tuple__238)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__238);
      __Pyx_GIVEREF(__pyx_tuple__238);

      /* "pandas/algos.pyx":785
     * # Rolling sum
     *
     * def roll_sum(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0
     *     cdef int nobs = 0, i
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_23roll_sum, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_sum, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__239 = (PyObject*)__Pyx_PyCode_New(3, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__238, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_sum, 785, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__239)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     786:     cdef double val, prev, sum_x = 0

      /* "pandas/algos.pyx":786
     *
     * def roll_sum(ndarray[double_t] input, int win, int minp):
     *     cdef double val, prev, sum_x = 0             # <<<<<<<<<<<<<<
     *     cdef int nobs = 0, i
     *     cdef int N = len(input)
     */
      __pyx_v_sum_x = 0.0;

     787:     cdef int nobs = 0, i

      /* "pandas/algos.pyx":787
     * def roll_sum(ndarray[double_t] input, int win, int minp):
     *     cdef double val, prev, sum_x = 0
     *     cdef int nobs = 0, i             # <<<<<<<<<<<<<<
     *     cdef int N = len(input)
     *
     */
      __pyx_v_nobs = 0;

     788:     cdef int N = len(input)

      /* "pandas/algos.pyx":788
     *     cdef double val, prev, sum_x = 0
     *     cdef int nobs = 0, i
     *     cdef int N = len(input)             # <<<<<<<<<<<<<<
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     789:

     790:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":790
     *     cdef int N = len(input)
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(win, minp, N)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     791:

     792:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":792
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     793:

     794:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":794
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     795:         val = input[i]

        /* "pandas/algos.pyx":795
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_8 = __pyx_v_i;
        __pyx_t_10 = -1;
        if (__pyx_t_8 < 0) {
          __pyx_t_8 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_8 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_input.diminfo[0].strides));

     796:

     797:         # Not NaN

     798:         if val == val:

        /* "pandas/algos.pyx":798
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             sum_x += val
     */
        __pyx_t_11 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_11) {

     799:             nobs += 1

          /* "pandas/algos.pyx":799
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             sum_x += val
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     800:             sum_x += val

          /* "pandas/algos.pyx":800
     *         if val == val:
     *             nobs += 1
     *             sum_x += val             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          __pyx_v_sum_x = (__pyx_v_sum_x + __pyx_v_val);
          goto __pyx_L5;
        }
        __pyx_L5:;

     801:

     802:         output[i] = NaN

        /* "pandas/algos.pyx":802
     *             sum_x += val
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_10 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_10 < 0) {
          __pyx_t_10 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_10 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     803:

     804:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":804
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     805:         val = input[i]

        /* "pandas/algos.pyx":805
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_14 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_14 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_14 = 0;
        if (unlikely(__pyx_t_14 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_14);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     806:

     807:         if val == val:

        /* "pandas/algos.pyx":807
     *         val = input[i]
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             sum_x += val
     */
        __pyx_t_11 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_11) {

     808:             nobs += 1

          /* "pandas/algos.pyx":808
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             sum_x += val
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     809:             sum_x += val

          /* "pandas/algos.pyx":809
     *         if val == val:
     *             nobs += 1
     *             sum_x += val             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
          __pyx_v_sum_x = (__pyx_v_sum_x + __pyx_v_val);
          goto __pyx_L8;
        }
        __pyx_L8:;

     810:

     811:         if i > win - 1:

        /* "pandas/algos.pyx":811
     *             sum_x += val
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *             if prev == prev:
     */
        __pyx_t_11 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_11) {

     812:             prev = input[i - win]

          /* "pandas/algos.pyx":812
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *             if prev == prev:
     *                 sum_x -= prev
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_15 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_15 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_15 = 0;
          if (unlikely(__pyx_t_15 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_15);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     813:             if prev == prev:

          /* "pandas/algos.pyx":813
     *         if i > win - 1:
     *             prev = input[i - win]
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 sum_x -= prev
     *                 nobs -= 1
     */
          __pyx_t_11 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_11) {

     814:                 sum_x -= prev

            /* "pandas/algos.pyx":814
     *             prev = input[i - win]
     *             if prev == prev:
     *                 sum_x -= prev             # <<<<<<<<<<<<<<
     *                 nobs -= 1
     *
     */
            __pyx_v_sum_x = (__pyx_v_sum_x - __pyx_v_prev);

     815:                 nobs -= 1

            /* "pandas/algos.pyx":815
     *             if prev == prev:
     *                 sum_x -= prev
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     816:

     817:         if nobs >= minp:

        /* "pandas/algos.pyx":817
     *                 nobs -= 1
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             output[i] = sum_x
     *         else:
     */
        __pyx_t_11 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_11) {

     818:             output[i] = sum_x

          /* "pandas/algos.pyx":818
     *
     *         if nobs >= minp:
     *             output[i] = sum_x             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_16 = -1;
          if (__pyx_t_15 < 0) {
            __pyx_t_15 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_15 < 0)) __pyx_t_16 = 0;
          } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_16 = 0;
          if (unlikely(__pyx_t_16 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_16);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_sum_x;
          goto __pyx_L11;
        }
        /*else*/ {

     819:         else:

     820:             output[i] = NaN

          /* "pandas/algos.pyx":820
     *             output[i] = sum_x
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     return output
     */
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_17 = -1;
          if (__pyx_t_16 < 0) {
            __pyx_t_16 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
          } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_17 = 0;
          if (unlikely(__pyx_t_17 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_17);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L11:;
      }

     821:

     822:     return output

      /* "pandas/algos.pyx":822
     *             output[i] = NaN
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * #-------------------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     823:

     824: #-------------------------------------------------------------------------------

     825: # Rolling mean

     826:

     827: def roll_mean(ndarray[double_t] input,

    /* "pandas/algos.pyx":827
     * # Rolling mean
     *
     * def roll_mean(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef:
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_25roll_mean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_25roll_mean = {__Pyx_NAMESTR("roll_mean"), (PyCFunction)__pyx_pw_6pandas_5algos_25roll_mean, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_25roll_mean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_mean (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_mean", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_mean", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_mean") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_mean", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_24roll_mean(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_24roll_mean(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      double __pyx_v_val;
      double __pyx_v_prev;
      double __pyx_v_result;
      double __pyx_v_sum_x;
      Py_ssize_t __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_neg_ct;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_mean", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":827
     * # Rolling mean
     *
     * def roll_mean(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef:
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":827
     * # Rolling mean
     *
     * def roll_mean(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef:
     */
      __pyx_tuple__240 = PyTuple_Pack(12, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_val, __pyx_n_s_prev, __pyx_n_s_result, __pyx_n_s_sum_x, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_neg_ct, __pyx_n_s_N, __pyx_n_s_output); if (unlikely(!__pyx_tuple__240)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__240);
      __Pyx_GIVEREF(__pyx_tuple__240);

      /* "pandas/algos.pyx":827
     * # Rolling mean
     *
     * def roll_mean(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef:
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_25roll_mean, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_mean, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__241 = (PyObject*)__Pyx_PyCode_New(3, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__240, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_mean, 827, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__241)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     828:                int win, int minp):

     829:     cdef:

     830:         double val, prev, result, sum_x = 0

      /* "pandas/algos.pyx":830
     *                int win, int minp):
     *     cdef:
     *         double val, prev, result, sum_x = 0             # <<<<<<<<<<<<<<
     *         Py_ssize_t nobs = 0, i, neg_ct = 0
     *         Py_ssize_t N = len(input)
     */
      __pyx_v_sum_x = 0.0;

     831:         Py_ssize_t nobs = 0, i, neg_ct = 0

      /* "pandas/algos.pyx":831
     *     cdef:
     *         double val, prev, result, sum_x = 0
     *         Py_ssize_t nobs = 0, i, neg_ct = 0             # <<<<<<<<<<<<<<
     *         Py_ssize_t N = len(input)
     *
     */
      __pyx_v_nobs = 0;
      __pyx_v_neg_ct = 0;

     832:         Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":832
     *         double val, prev, result, sum_x = 0
     *         Py_ssize_t nobs = 0, i, neg_ct = 0
     *         Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     833:

     834:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":834
     *         Py_ssize_t N = len(input)
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *     minp = _check_minp(win, minp, N)
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     835:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":835
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     836:

     837:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":837
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     838:         val = input[i]

        /* "pandas/algos.pyx":838
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_input.diminfo[0].strides));

     839:

     840:         # Not NaN

     841:         if val == val:

        /* "pandas/algos.pyx":841
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             sum_x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     842:             nobs += 1

          /* "pandas/algos.pyx":842
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             sum_x += val
     *             if signbit(val):
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     843:             sum_x += val

          /* "pandas/algos.pyx":843
     *         if val == val:
     *             nobs += 1
     *             sum_x += val             # <<<<<<<<<<<<<<
     *             if signbit(val):
     *                 neg_ct += 1
     */
          __pyx_v_sum_x = (__pyx_v_sum_x + __pyx_v_val);

     844:             if signbit(val):

          /* "pandas/algos.pyx":844
     *             nobs += 1
     *             sum_x += val
     *             if signbit(val):             # <<<<<<<<<<<<<<
     *                 neg_ct += 1
     *
     */
          __pyx_t_10 = (signbit(__pyx_v_val) != 0);
          if (__pyx_t_10) {

     845:                 neg_ct += 1

            /* "pandas/algos.pyx":845
     *             sum_x += val
     *             if signbit(val):
     *                 neg_ct += 1             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
            __pyx_v_neg_ct = (__pyx_v_neg_ct + 1);
            goto __pyx_L6;
          }
          __pyx_L6:;
          goto __pyx_L5;
        }
        __pyx_L5:;

     846:

     847:         output[i] = NaN

        /* "pandas/algos.pyx":847
     *                 neg_ct += 1
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     848:

     849:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":849
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     850:         val = input[i]

        /* "pandas/algos.pyx":850
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     851:

     852:         if val == val:

        /* "pandas/algos.pyx":852
     *         val = input[i]
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             sum_x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     853:             nobs += 1

          /* "pandas/algos.pyx":853
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             sum_x += val
     *             if signbit(val):
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     854:             sum_x += val

          /* "pandas/algos.pyx":854
     *         if val == val:
     *             nobs += 1
     *             sum_x += val             # <<<<<<<<<<<<<<
     *             if signbit(val):
     *                 neg_ct += 1
     */
          __pyx_v_sum_x = (__pyx_v_sum_x + __pyx_v_val);

     855:             if signbit(val):

          /* "pandas/algos.pyx":855
     *             nobs += 1
     *             sum_x += val
     *             if signbit(val):             # <<<<<<<<<<<<<<
     *                 neg_ct += 1
     *
     */
          __pyx_t_10 = (signbit(__pyx_v_val) != 0);
          if (__pyx_t_10) {

     856:                 neg_ct += 1

            /* "pandas/algos.pyx":856
     *             sum_x += val
     *             if signbit(val):
     *                 neg_ct += 1             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
            __pyx_v_neg_ct = (__pyx_v_neg_ct + 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     857:

     858:         if i > win - 1:

        /* "pandas/algos.pyx":858
     *                 neg_ct += 1
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *             if prev == prev:
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     859:             prev = input[i - win]

          /* "pandas/algos.pyx":859
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *             if prev == prev:
     *                 sum_x -= prev
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     860:             if prev == prev:

          /* "pandas/algos.pyx":860
     *         if i > win - 1:
     *             prev = input[i - win]
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 sum_x -= prev
     *                 nobs -= 1
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     861:                 sum_x -= prev

            /* "pandas/algos.pyx":861
     *             prev = input[i - win]
     *             if prev == prev:
     *                 sum_x -= prev             # <<<<<<<<<<<<<<
     *                 nobs -= 1
     *                 if signbit(prev):
     */
            __pyx_v_sum_x = (__pyx_v_sum_x - __pyx_v_prev);

     862:                 nobs -= 1

            /* "pandas/algos.pyx":862
     *             if prev == prev:
     *                 sum_x -= prev
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *                 if signbit(prev):
     *                     neg_ct -= 1
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);

     863:                 if signbit(prev):

            /* "pandas/algos.pyx":863
     *                 sum_x -= prev
     *                 nobs -= 1
     *                 if signbit(prev):             # <<<<<<<<<<<<<<
     *                     neg_ct -= 1
     *
     */
            __pyx_t_10 = (signbit(__pyx_v_prev) != 0);
            if (__pyx_t_10) {

     864:                     neg_ct -= 1

              /* "pandas/algos.pyx":864
     *                 nobs -= 1
     *                 if signbit(prev):
     *                     neg_ct -= 1             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
              __pyx_v_neg_ct = (__pyx_v_neg_ct - 1);
              goto __pyx_L13;
            }
            __pyx_L13:;
            goto __pyx_L12;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        __pyx_L11:;

     865:

     866:         if nobs >= minp:

        /* "pandas/algos.pyx":866
     *                     neg_ct -= 1
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             result = sum_x / nobs
     *             if neg_ct == 0 and result < 0:
     */
        __pyx_t_10 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_10) {

     867:             result = sum_x / nobs

          /* "pandas/algos.pyx":867
     *
     *         if nobs >= minp:
     *             result = sum_x / nobs             # <<<<<<<<<<<<<<
     *             if neg_ct == 0 and result < 0:
     *                 # all positive
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_result = (__pyx_v_sum_x / __pyx_v_nobs);

     868:             if neg_ct == 0 and result < 0:

          /* "pandas/algos.pyx":868
     *         if nobs >= minp:
     *             result = sum_x / nobs
     *             if neg_ct == 0 and result < 0:             # <<<<<<<<<<<<<<
     *                 # all positive
     *                 output[i] = 0
     */
          __pyx_t_10 = ((__pyx_v_neg_ct == 0) != 0);
          if (__pyx_t_10) {
            __pyx_t_15 = ((__pyx_v_result < 0.0) != 0);
            __pyx_t_16 = __pyx_t_15;
          } else {
            __pyx_t_16 = __pyx_t_10;
          }
          if (__pyx_t_16) {

     869:                 # all positive

     870:                 output[i] = 0

            /* "pandas/algos.pyx":870
     *             if neg_ct == 0 and result < 0:
     *                 # all positive
     *                 output[i] = 0             # <<<<<<<<<<<<<<
     *             elif neg_ct == nobs and result > 0:
     *                 # all negative
     */
            __pyx_t_17 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_17 < 0) {
              __pyx_t_17 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_17 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_output.diminfo[0].strides) = 0.0;
            goto __pyx_L15;
          }

     871:             elif neg_ct == nobs and result > 0:

          /* "pandas/algos.pyx":871
     *                 # all positive
     *                 output[i] = 0
     *             elif neg_ct == nobs and result > 0:             # <<<<<<<<<<<<<<
     *                 # all negative
     *                 output[i] = 0
     */
          __pyx_t_16 = ((__pyx_v_neg_ct == __pyx_v_nobs) != 0);
          if (__pyx_t_16) {
            __pyx_t_10 = ((__pyx_v_result > 0.0) != 0);
            __pyx_t_15 = __pyx_t_10;
          } else {
            __pyx_t_15 = __pyx_t_16;
          }
          if (__pyx_t_15) {

     872:                 # all negative

     873:                 output[i] = 0

            /* "pandas/algos.pyx":873
     *             elif neg_ct == nobs and result > 0:
     *                 # all negative
     *                 output[i] = 0             # <<<<<<<<<<<<<<
     *             else:
     *                 output[i] = result
     */
            __pyx_t_18 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_18 < 0) {
              __pyx_t_18 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_18 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_output.diminfo[0].strides) = 0.0;
            goto __pyx_L15;
          }
          /*else*/ {

     874:             else:

     875:                 output[i] = result

            /* "pandas/algos.pyx":875
     *                 output[i] = 0
     *             else:
     *                 output[i] = result             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
            __pyx_t_19 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_19 < 0) {
              __pyx_t_19 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_19 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_result;
          }
          __pyx_L15:;
          goto __pyx_L14;
        }
        /*else*/ {

     876:         else:

     877:             output[i] = NaN

          /* "pandas/algos.pyx":877
     *                 output[i] = result
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     return output
     */
          __pyx_t_20 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L14:;
      }

     878:

     879:     return output

      /* "pandas/algos.pyx":879
     *             output[i] = NaN
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * #-------------------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     880:

     881: #-------------------------------------------------------------------------------

     882: # Exponentially weighted moving average

     883:

     884: def ewma(ndarray[double_t] input, double_t com, int adjust):

    /* "pandas/algos.pyx":884
     * # Exponentially weighted moving average
     *
     * def ewma(ndarray[double_t] input, double_t com, int adjust):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute exponentially-weighted moving average using center-of-mass.
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_27ewma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_26ewma[] = "\n    Compute exponentially-weighted moving average using center-of-mass.\n\n    Parameters\n    ----------\n    input : ndarray (float64 type)\n    com : float64\n\n    Returns\n    -------\n    y : ndarray\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_27ewma = {__Pyx_NAMESTR("ewma"), (PyCFunction)__pyx_pw_6pandas_5algos_27ewma, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_26ewma)};
    static PyObject *__pyx_pw_6pandas_5algos_27ewma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      __pyx_t_5numpy_double_t __pyx_v_com;
      int __pyx_v_adjust;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("ewma (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_com,&__pyx_n_s_adjust,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_com)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("ewma", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_adjust)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("ewma", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ewma") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_com = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_com == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_adjust = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_adjust == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("ewma", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.ewma", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_26ewma(__pyx_self, __pyx_v_input, __pyx_v_com, __pyx_v_adjust);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_26ewma(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, __pyx_t_5numpy_double_t __pyx_v_com, int __pyx_v_adjust) {
      double __pyx_v_cur;
      double __pyx_v_prev;
      double __pyx_v_neww;
      double __pyx_v_oldw;
      double __pyx_v_adj;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("ewma", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":884
     * # Exponentially weighted moving average
     *
     * def ewma(ndarray[double_t] input, double_t com, int adjust):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute exponentially-weighted moving average using center-of-mass.
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.ewma", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":884
     * # Exponentially weighted moving average
     *
     * def ewma(ndarray[double_t] input, double_t com, int adjust):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute exponentially-weighted moving average using center-of-mass.
     */
      __pyx_tuple__242 = PyTuple_Pack(11, __pyx_n_s_input, __pyx_n_s_com, __pyx_n_s_adjust, __pyx_n_s_cur, __pyx_n_s_prev, __pyx_n_s_neww, __pyx_n_s_oldw, __pyx_n_s_adj, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output); if (unlikely(!__pyx_tuple__242)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__242);
      __Pyx_GIVEREF(__pyx_tuple__242);

      /* "pandas/algos.pyx":884
     * # Exponentially weighted moving average
     *
     * def ewma(ndarray[double_t] input, double_t com, int adjust):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute exponentially-weighted moving average using center-of-mass.
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_27ewma, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ewma, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__243 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__242, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_ewma, 884, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__243)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     885:     '''

     886:     Compute exponentially-weighted moving average using center-of-mass.

     887:

     888:     Parameters

     889:     ----------

     890:     input : ndarray (float64 type)

     891:     com : float64

     892:

     893:     Returns

     894:     -------

     895:     y : ndarray

     896:     '''

     897:

     898:     cdef double cur, prev, neww, oldw, adj

     899:     cdef Py_ssize_t i

     900:     cdef Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":900
     *     cdef double cur, prev, neww, oldw, adj
     *     cdef Py_ssize_t i
     *     cdef Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     901:

     902:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":902
     *     cdef Py_ssize_t N = len(input)
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     if N == 0:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     903:

     904:     if N == 0:

      /* "pandas/algos.pyx":904
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     *     if N == 0:             # <<<<<<<<<<<<<<
     *         return output
     *
     */
      __pyx_t_7 = ((__pyx_v_N == 0) != 0);
      if (__pyx_t_7) {

     905:         return output

        /* "pandas/algos.pyx":905
     *
     *     if N == 0:
     *         return output             # <<<<<<<<<<<<<<
     *
     *     neww = 1. / (1. + com)
     */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(((PyObject *)__pyx_v_output));
        __pyx_r = ((PyObject *)__pyx_v_output);
        goto __pyx_L0;
      }

     906:

     907:     neww = 1. / (1. + com)

      /* "pandas/algos.pyx":907
     *         return output
     *
     *     neww = 1. / (1. + com)             # <<<<<<<<<<<<<<
     *     oldw = 1. - neww
     *     adj = oldw
     */
      __pyx_t_8 = (1. + __pyx_v_com);
      if (unlikely(__pyx_t_8 == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_neww = (1. / __pyx_t_8);

     908:     oldw = 1. - neww

      /* "pandas/algos.pyx":908
     *
     *     neww = 1. / (1. + com)
     *     oldw = 1. - neww             # <<<<<<<<<<<<<<
     *     adj = oldw
     *
     */
      __pyx_v_oldw = (1. - __pyx_v_neww);

     909:     adj = oldw

      /* "pandas/algos.pyx":909
     *     neww = 1. / (1. + com)
     *     oldw = 1. - neww
     *     adj = oldw             # <<<<<<<<<<<<<<
     *
     *     if adjust:
     */
      __pyx_v_adj = __pyx_v_oldw;

     910:

     911:     if adjust:

      /* "pandas/algos.pyx":911
     *     adj = oldw
     *
     *     if adjust:             # <<<<<<<<<<<<<<
     *         output[0] = neww * input[0]
     *     else:
     */
      __pyx_t_7 = (__pyx_v_adjust != 0);
      if (__pyx_t_7) {

     912:         output[0] = neww * input[0]

        /* "pandas/algos.pyx":912
     *
     *     if adjust:
     *         output[0] = neww * input[0]             # <<<<<<<<<<<<<<
     *     else:
     *         output[0] = input[0]
     */
        __pyx_t_9 = 0;
        __pyx_t_10 = -1;
        if (__pyx_t_9 < 0) {
          __pyx_t_9 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_11 = 0;
        __pyx_t_10 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = (__pyx_v_neww * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_input.diminfo[0].strides)));
        goto __pyx_L4;
      }
      /*else*/ {

     913:     else:

     914:         output[0] = input[0]

        /* "pandas/algos.pyx":914
     *         output[0] = neww * input[0]
     *     else:
     *         output[0] = input[0]             # <<<<<<<<<<<<<<
     *
     *     for i from 1 <= i < N:
     */
        __pyx_t_12 = 0;
        __pyx_t_10 = -1;
        if (__pyx_t_12 < 0) {
          __pyx_t_12 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_12 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_13 = 0;
        __pyx_t_10 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_output.diminfo[0].strides) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_input.diminfo[0].strides));
      }
      __pyx_L4:;

     915:

     916:     for i from 1 <= i < N:

      /* "pandas/algos.pyx":916
     *         output[0] = input[0]
     *
     *     for i from 1 <= i < N:             # <<<<<<<<<<<<<<
     *         cur = input[i]
     *         prev = output[i - 1]
     */
      __pyx_t_1 = __pyx_v_N;
      for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     917:         cur = input[i]

        /* "pandas/algos.pyx":917
     *
     *     for i from 1 <= i < N:
     *         cur = input[i]             # <<<<<<<<<<<<<<
     *         prev = output[i - 1]
     *
     */
        __pyx_t_14 = __pyx_v_i;
        __pyx_t_10 = -1;
        if (__pyx_t_14 < 0) {
          __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_14 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_cur = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     918:         prev = output[i - 1]

        /* "pandas/algos.pyx":918
     *     for i from 1 <= i < N:
     *         cur = input[i]
     *         prev = output[i - 1]             # <<<<<<<<<<<<<<
     *
     *         if cur == cur:
     */
        __pyx_t_15 = (__pyx_v_i - 1);
        __pyx_t_10 = -1;
        if (__pyx_t_15 < 0) {
          __pyx_t_15 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_15 < 0)) __pyx_t_10 = 0;
        } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
        if (unlikely(__pyx_t_10 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_10);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_output.diminfo[0].strides));

     919:

     920:         if cur == cur:

        /* "pandas/algos.pyx":920
     *         prev = output[i - 1]
     *
     *         if cur == cur:             # <<<<<<<<<<<<<<
     *             if prev == prev:
     *                 output[i] = oldw * prev + neww * cur
     */
        __pyx_t_7 = ((__pyx_v_cur == __pyx_v_cur) != 0);
        if (__pyx_t_7) {

     921:             if prev == prev:

          /* "pandas/algos.pyx":921
     *
     *         if cur == cur:
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 output[i] = oldw * prev + neww * cur
     *             else:
     */
          __pyx_t_7 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_7) {

     922:                 output[i] = oldw * prev + neww * cur

            /* "pandas/algos.pyx":922
     *         if cur == cur:
     *             if prev == prev:
     *                 output[i] = oldw * prev + neww * cur             # <<<<<<<<<<<<<<
     *             else:
     *                 output[i] = neww * cur
     */
            __pyx_t_16 = __pyx_v_i;
            __pyx_t_10 = -1;
            if (__pyx_t_16 < 0) {
              __pyx_t_16 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_16 < 0)) __pyx_t_10 = 0;
            } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
            if (unlikely(__pyx_t_10 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_10);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_output.diminfo[0].strides) = ((__pyx_v_oldw * __pyx_v_prev) + (__pyx_v_neww * __pyx_v_cur));
            goto __pyx_L8;
          }
          /*else*/ {

     923:             else:

     924:                 output[i] = neww * cur

            /* "pandas/algos.pyx":924
     *                 output[i] = oldw * prev + neww * cur
     *             else:
     *                 output[i] = neww * cur             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = prev
     */
            __pyx_t_17 = __pyx_v_i;
            __pyx_t_10 = -1;
            if (__pyx_t_17 < 0) {
              __pyx_t_17 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_17 < 0)) __pyx_t_10 = 0;
            } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
            if (unlikely(__pyx_t_10 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_10);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_output.diminfo[0].strides) = (__pyx_v_neww * __pyx_v_cur);
          }
          __pyx_L8:;
          goto __pyx_L7;
        }
        /*else*/ {

     925:         else:

     926:             output[i] = prev

          /* "pandas/algos.pyx":926
     *                 output[i] = neww * cur
     *         else:
     *             output[i] = prev             # <<<<<<<<<<<<<<
     *
     *     if adjust:
     */
          __pyx_t_18 = __pyx_v_i;
          __pyx_t_10 = -1;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_10 = 0;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
          if (unlikely(__pyx_t_10 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_10);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_prev;
        }
        __pyx_L7:;
      }

     927:

     928:     if adjust:

      /* "pandas/algos.pyx":928
     *             output[i] = prev
     *
     *     if adjust:             # <<<<<<<<<<<<<<
     *         for i from 0 <= i < N:
     *             cur = input[i]
     */
      __pyx_t_7 = (__pyx_v_adjust != 0);
      if (__pyx_t_7) {

     929:         for i from 0 <= i < N:

        /* "pandas/algos.pyx":929
     *
     *     if adjust:
     *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
     *             cur = input[i]
     *
     */
        __pyx_t_1 = __pyx_v_N;
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     930:             cur = input[i]

          /* "pandas/algos.pyx":930
     *     if adjust:
     *         for i from 0 <= i < N:
     *             cur = input[i]             # <<<<<<<<<<<<<<
     *
     *             if cur == cur:
     */
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_10 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_10 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_10 = 0;
          if (unlikely(__pyx_t_10 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_10);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_cur = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_input.diminfo[0].strides));

     931:

     932:             if cur == cur:

          /* "pandas/algos.pyx":932
     *             cur = input[i]
     *
     *             if cur == cur:             # <<<<<<<<<<<<<<
     *                 output[i] = output[i] / (1. - adj)
     *                 adj *= oldw
     */
          __pyx_t_7 = ((__pyx_v_cur == __pyx_v_cur) != 0);
          if (__pyx_t_7) {

     933:                 output[i] = output[i] / (1. - adj)

            /* "pandas/algos.pyx":933
     *
     *             if cur == cur:
     *                 output[i] = output[i] / (1. - adj)             # <<<<<<<<<<<<<<
     *                 adj *= oldw
     *             else:
     */
            __pyx_t_20 = __pyx_v_i;
            __pyx_t_10 = -1;
            if (__pyx_t_20 < 0) {
              __pyx_t_20 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_20 < 0)) __pyx_t_10 = 0;
            } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
            if (unlikely(__pyx_t_10 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_10);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_8 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_output.diminfo[0].strides));
            __pyx_t_21 = (1. - __pyx_v_adj);
            if (unlikely(__pyx_t_21 == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "float division");
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_22 = __pyx_v_i;
            __pyx_t_10 = -1;
            if (__pyx_t_22 < 0) {
              __pyx_t_22 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_22 < 0)) __pyx_t_10 = 0;
            } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
            if (unlikely(__pyx_t_10 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_10);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_output.diminfo[0].strides) = (__pyx_t_8 / __pyx_t_21);

     934:                 adj *= oldw

            /* "pandas/algos.pyx":934
     *             if cur == cur:
     *                 output[i] = output[i] / (1. - adj)
     *                 adj *= oldw             # <<<<<<<<<<<<<<
     *             else:
     *                 if i >= 1:
     */
            __pyx_v_adj = (__pyx_v_adj * __pyx_v_oldw);
            goto __pyx_L12;
          }
          /*else*/ {

     935:             else:

     936:                 if i >= 1:

            /* "pandas/algos.pyx":936
     *                 adj *= oldw
     *             else:
     *                 if i >= 1:             # <<<<<<<<<<<<<<
     *                     output[i] = output[i - 1]
     *
     */
            __pyx_t_7 = ((__pyx_v_i >= 1) != 0);
            if (__pyx_t_7) {

     937:                     output[i] = output[i - 1]

              /* "pandas/algos.pyx":937
     *             else:
     *                 if i >= 1:
     *                     output[i] = output[i - 1]             # <<<<<<<<<<<<<<
     *
     *     return output
     */
              __pyx_t_23 = (__pyx_v_i - 1);
              __pyx_t_10 = -1;
              if (__pyx_t_23 < 0) {
                __pyx_t_23 += __pyx_pybuffernd_output.diminfo[0].shape;
                if (unlikely(__pyx_t_23 < 0)) __pyx_t_10 = 0;
              } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
              if (unlikely(__pyx_t_10 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_10);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_24 = __pyx_v_i;
              __pyx_t_10 = -1;
              if (__pyx_t_24 < 0) {
                __pyx_t_24 += __pyx_pybuffernd_output.diminfo[0].shape;
                if (unlikely(__pyx_t_24 < 0)) __pyx_t_10 = 0;
              } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_10 = 0;
              if (unlikely(__pyx_t_10 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_10);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_output.diminfo[0].strides) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_output.diminfo[0].strides));
              goto __pyx_L13;
            }
            __pyx_L13:;
          }
          __pyx_L12:;
        }
        goto __pyx_L9;
      }
      __pyx_L9:;

     938:

     939:     return output

      /* "pandas/algos.pyx":939
     *                     output[i] = output[i - 1]
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * #----------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     940:

     941: #----------------------------------------------------------------------

     942: # Pairwise correlation/covariance

     943:

     944: @cython.boundscheck(False)

     945: @cython.wraparound(False)

     946: def nancorr(ndarray[float64_t, ndim=2] mat, cov=False, minp=None):

    /* "pandas/algos.pyx":946
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr(ndarray[float64_t, ndim=2] mat, cov=False, minp=None):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_29nancorr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_29nancorr = {__Pyx_NAMESTR("nancorr"), (PyCFunction)__pyx_pw_6pandas_5algos_29nancorr, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_29nancorr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_mat = 0;
      PyObject *__pyx_v_cov = 0;
      PyObject *__pyx_v_minp = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("nancorr (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mat,&__pyx_n_s_cov,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        values[1] = ((PyObject *)Py_False);
        values[2] = ((PyObject *)Py_None);
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cov);
              if (value) { values[1] = value; kw_args--; }
            }
            case  2:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp);
              if (value) { values[2] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nancorr") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_mat = ((PyArrayObject *)values[0]);
        __pyx_v_cov = values[1];
        __pyx_v_minp = values[2];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("nancorr", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.nancorr", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mat), __pyx_ptype_5numpy_ndarray, 1, "mat", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_28nancorr(__pyx_self, __pyx_v_mat, __pyx_v_cov, __pyx_v_minp);

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_28nancorr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_mat, PyObject *__pyx_v_cov, PyObject *__pyx_v_minp) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_xi;
      Py_ssize_t __pyx_v_yi;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      PyArrayObject *__pyx_v_result = 0;
      PyArrayObject *__pyx_v_mask = 0;
      __pyx_t_5numpy_int64_t __pyx_v_nobs;
      __pyx_t_5numpy_float64_t __pyx_v_vx;
      __pyx_t_5numpy_float64_t __pyx_v_vy;
      __pyx_t_5numpy_float64_t __pyx_v_sumx;
      __pyx_t_5numpy_float64_t __pyx_v_sumy;
      __pyx_t_5numpy_float64_t __pyx_v_sumxx;
      __pyx_t_5numpy_float64_t __pyx_v_sumyy;
      __pyx_t_5numpy_float64_t __pyx_v_meanx;
      __pyx_t_5numpy_float64_t __pyx_v_meany;
      __pyx_t_5numpy_float64_t __pyx_v_divisor;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_mask;
      __Pyx_Buffer __pyx_pybuffer_mask;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_mat;
      __Pyx_Buffer __pyx_pybuffer_mat;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("nancorr", 0);
      __Pyx_INCREF(__pyx_v_minp);
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_mask.pybuffer.buf = NULL;
      __pyx_pybuffer_mask.refcount = 0;
      __pyx_pybuffernd_mask.data = NULL;
      __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask;
      __pyx_pybuffer_mat.pybuffer.buf = NULL;
      __pyx_pybuffer_mat.refcount = 0;
      __pyx_pybuffernd_mat.data = NULL;
      __pyx_pybuffernd_mat.rcbuffer = &__pyx_pybuffer_mat;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mat.rcbuffer->pybuffer, (PyObject*)__pyx_v_mat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_mat.diminfo[0].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mat.diminfo[0].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mat.diminfo[1].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mat.diminfo[1].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[1];

      /* "pandas/algos.pyx":946
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr(ndarray[float64_t, ndim=2] mat, cov=False, minp=None):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_10);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.nancorr", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_result);
      __Pyx_XDECREF((PyObject *)__pyx_v_mask);
      __Pyx_XDECREF(__pyx_v_minp);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":946
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr(ndarray[float64_t, ndim=2] mat, cov=False, minp=None):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */
      __pyx_tuple__244 = PyTuple_Pack(21, __pyx_n_s_mat, __pyx_n_s_cov, __pyx_n_s_minp, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_xi, __pyx_n_s_yi, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_result, __pyx_n_s_mask, __pyx_n_s_nobs, __pyx_n_s_vx, __pyx_n_s_vy, __pyx_n_s_sumx, __pyx_n_s_sumy, __pyx_n_s_sumxx, __pyx_n_s_sumyy, __pyx_n_s_meanx, __pyx_n_s_meany, __pyx_n_s_divisor); if (unlikely(!__pyx_tuple__244)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__244);
      __Pyx_GIVEREF(__pyx_tuple__244);

      /* "pandas/algos.pyx":946
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr(ndarray[float64_t, ndim=2] mat, cov=False, minp=None):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_29nancorr, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_nancorr, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__245 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__244, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_nancorr, 946, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__245)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     947:     cdef:

     948:         Py_ssize_t i, j, xi, yi, N, K

     949:         ndarray[float64_t, ndim=2] result

     950:         ndarray[uint8_t, ndim=2] mask

     951:         int64_t nobs = 0

      /* "pandas/algos.pyx":951
     *         ndarray[float64_t, ndim=2] result
     *         ndarray[uint8_t, ndim=2] mask
     *         int64_t nobs = 0             # <<<<<<<<<<<<<<
     *         float64_t vx, vy, sumx, sumy, sumxx, sumyy, meanx, meany, divisor
     *
     */
      __pyx_v_nobs = 0;

     952:         float64_t vx, vy, sumx, sumy, sumxx, sumyy, meanx, meany, divisor

     953:

     954:     N, K = (<object> mat).shape

      /* "pandas/algos.pyx":954
     *         float64_t vx, vy, sumx, sumy, sumxx, sumyy, meanx, meany, divisor
     *
     *     N, K = (<object> mat).shape             # <<<<<<<<<<<<<<
     *
     *     if minp is None:
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mat), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_6;
      __pyx_v_K = __pyx_t_7;

     955:

     956:     if minp is None:

      /* "pandas/algos.pyx":956
     *     N, K = (<object> mat).shape
     *
     *     if minp is None:             # <<<<<<<<<<<<<<
     *         minp = 1
     *
     */
      __pyx_t_8 = (__pyx_v_minp == Py_None);
      __pyx_t_9 = (__pyx_t_8 != 0);
      if (__pyx_t_9) {

     957:         minp = 1

        /* "pandas/algos.pyx":957
     *
     *     if minp is None:
     *         minp = 1             # <<<<<<<<<<<<<<
     *
     *     result = np.empty((K, K), dtype=np.float64)
     */
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_DECREF_SET(__pyx_v_minp, __pyx_int_1);
        goto __pyx_L5;
      }
      __pyx_L5:;

     958:

     959:     result = np.empty((K, K), dtype=np.float64)

      /* "pandas/algos.pyx":959
     *         minp = 1
     *
     *     result = np.empty((K, K), dtype=np.float64)             # <<<<<<<<<<<<<<
     *     mask = np.isfinite(mat).view(np.uint8)
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_K); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_K); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_12 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          }
        }
        __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = 0;
      __pyx_v_result = ((PyArrayObject *)__pyx_t_10);
      __pyx_t_10 = 0;

     960:     mask = np.isfinite(mat).view(np.uint8)

      /* "pandas/algos.pyx":960
     *
     *     result = np.empty((K, K), dtype=np.float64)
     *     mask = np.isfinite(mat).view(np.uint8)             # <<<<<<<<<<<<<<
     *
     *     for xi in range(K):
     */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_isfinite); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(((PyObject *)__pyx_v_mat));
      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_mat));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mat));
      __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_view); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
        __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_12 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_16 = 0;
      __pyx_v_mask = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

     961:

     962:     for xi in range(K):

      /* "pandas/algos.pyx":962
     *     mask = np.isfinite(mat).view(np.uint8)
     *
     *     for xi in range(K):             # <<<<<<<<<<<<<<
     *         for yi in range(xi + 1):
     *             nobs = sumxx = sumyy = sumx = sumy = 0
     */
      __pyx_t_7 = __pyx_v_K;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6+=1) {
        __pyx_v_xi = __pyx_t_6;

     963:         for yi in range(xi + 1):

        /* "pandas/algos.pyx":963
     *
     *     for xi in range(K):
     *         for yi in range(xi + 1):             # <<<<<<<<<<<<<<
     *             nobs = sumxx = sumyy = sumx = sumy = 0
     *             for i in range(N):
     */
        __pyx_t_17 = (__pyx_v_xi + 1);
        for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
          __pyx_v_yi = __pyx_t_18;

     964:             nobs = sumxx = sumyy = sumx = sumy = 0

          /* "pandas/algos.pyx":964
     *     for xi in range(K):
     *         for yi in range(xi + 1):
     *             nobs = sumxx = sumyy = sumx = sumy = 0             # <<<<<<<<<<<<<<
     *             for i in range(N):
     *                 if mask[i, xi] and mask[i, yi]:
     */
          __pyx_v_nobs = 0;
          __pyx_v_sumxx = 0;
          __pyx_v_sumyy = 0;
          __pyx_v_sumx = 0;
          __pyx_v_sumy = 0;

     965:             for i in range(N):

          /* "pandas/algos.pyx":965
     *         for yi in range(xi + 1):
     *             nobs = sumxx = sumyy = sumx = sumy = 0
     *             for i in range(N):             # <<<<<<<<<<<<<<
     *                 if mask[i, xi] and mask[i, yi]:
     *                     vx = mat[i, xi]
     */
          __pyx_t_19 = __pyx_v_N;
          for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
            __pyx_v_i = __pyx_t_20;

     966:                 if mask[i, xi] and mask[i, yi]:

            /* "pandas/algos.pyx":966
     *             nobs = sumxx = sumyy = sumx = sumy = 0
     *             for i in range(N):
     *                 if mask[i, xi] and mask[i, yi]:             # <<<<<<<<<<<<<<
     *                     vx = mat[i, xi]
     *                     vy = mat[i, yi]
     */
            __pyx_t_21 = __pyx_v_i;
            __pyx_t_22 = __pyx_v_xi;
            __pyx_t_9 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
            if (__pyx_t_9) {
              __pyx_t_23 = __pyx_v_i;
              __pyx_t_24 = __pyx_v_yi;
              __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
              __pyx_t_25 = __pyx_t_8;
            } else {
              __pyx_t_25 = __pyx_t_9;
            }
            if (__pyx_t_25) {

     967:                     vx = mat[i, xi]

              /* "pandas/algos.pyx":967
     *             for i in range(N):
     *                 if mask[i, xi] and mask[i, yi]:
     *                     vx = mat[i, xi]             # <<<<<<<<<<<<<<
     *                     vy = mat[i, yi]
     *                     nobs += 1
     */
              __pyx_t_26 = __pyx_v_i;
              __pyx_t_27 = __pyx_v_xi;
              __pyx_v_vx = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_mat.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_mat.diminfo[1].strides));

     968:                     vy = mat[i, yi]

              /* "pandas/algos.pyx":968
     *                 if mask[i, xi] and mask[i, yi]:
     *                     vx = mat[i, xi]
     *                     vy = mat[i, yi]             # <<<<<<<<<<<<<<
     *                     nobs += 1
     *                     sumx += vx
     */
              __pyx_t_28 = __pyx_v_i;
              __pyx_t_29 = __pyx_v_yi;
              __pyx_v_vy = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mat.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_mat.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_mat.diminfo[1].strides));

     969:                     nobs += 1

              /* "pandas/algos.pyx":969
     *                     vx = mat[i, xi]
     *                     vy = mat[i, yi]
     *                     nobs += 1             # <<<<<<<<<<<<<<
     *                     sumx += vx
     *                     sumy += vy
     */
              __pyx_v_nobs = (__pyx_v_nobs + 1);

     970:                     sumx += vx

              /* "pandas/algos.pyx":970
     *                     vy = mat[i, yi]
     *                     nobs += 1
     *                     sumx += vx             # <<<<<<<<<<<<<<
     *                     sumy += vy
     *
     */
              __pyx_v_sumx = (__pyx_v_sumx + __pyx_v_vx);

     971:                     sumy += vy

              /* "pandas/algos.pyx":971
     *                     nobs += 1
     *                     sumx += vx
     *                     sumy += vy             # <<<<<<<<<<<<<<
     *
     *             if nobs < minp:
     */
              __pyx_v_sumy = (__pyx_v_sumy + __pyx_v_vy);
              goto __pyx_L12;
            }
            __pyx_L12:;
          }

     972:

     973:             if nobs < minp:

          /* "pandas/algos.pyx":973
     *                     sumy += vy
     *
     *             if nobs < minp:             # <<<<<<<<<<<<<<
     *                 result[xi, yi] = result[yi, xi] = np.NaN
     *             else:
     */
          __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_nobs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_v_minp, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_25) {

     974:                 result[xi, yi] = result[yi, xi] = np.NaN

            /* "pandas/algos.pyx":974
     *
     *             if nobs < minp:
     *                 result[xi, yi] = result[yi, xi] = np.NaN             # <<<<<<<<<<<<<<
     *             else:
     *                 meanx = sumx / nobs
     */
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NaN); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_30 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_30 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_19 = __pyx_v_xi;
            __pyx_t_20 = __pyx_v_yi;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_30;
            __pyx_t_30 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_30 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_31 = __pyx_v_yi;
            __pyx_t_32 = __pyx_v_xi;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_30;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L13;
          }
          /*else*/ {

     975:             else:

     976:                 meanx = sumx / nobs

            /* "pandas/algos.pyx":976
     *                 result[xi, yi] = result[yi, xi] = np.NaN
     *             else:
     *                 meanx = sumx / nobs             # <<<<<<<<<<<<<<
     *                 meany = sumy / nobs
     *
     */
            if (unlikely(__pyx_v_nobs == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "float division");
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_meanx = (__pyx_v_sumx / __pyx_v_nobs);

     977:                 meany = sumy / nobs

            /* "pandas/algos.pyx":977
     *             else:
     *                 meanx = sumx / nobs
     *                 meany = sumy / nobs             # <<<<<<<<<<<<<<
     *
     *                 # now the cov numerator
     */
            if (unlikely(__pyx_v_nobs == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "float division");
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_meany = (__pyx_v_sumy / __pyx_v_nobs);

     978:

     979:                 # now the cov numerator

     980:                 sumx = 0

            /* "pandas/algos.pyx":980
     *
     *                 # now the cov numerator
     *                 sumx = 0             # <<<<<<<<<<<<<<
     *
     *                 for i in range(N):
     */
            __pyx_v_sumx = 0.0;

     981:

     982:                 for i in range(N):

            /* "pandas/algos.pyx":982
     *                 sumx = 0
     *
     *                 for i in range(N):             # <<<<<<<<<<<<<<
     *                     if mask[i, xi] and mask[i, yi]:
     *                         vx = mat[i, xi] - meanx
     */
            __pyx_t_33 = __pyx_v_N;
            for (__pyx_t_34 = 0; __pyx_t_34 < __pyx_t_33; __pyx_t_34+=1) {
              __pyx_v_i = __pyx_t_34;

     983:                     if mask[i, xi] and mask[i, yi]:

              /* "pandas/algos.pyx":983
     *
     *                 for i in range(N):
     *                     if mask[i, xi] and mask[i, yi]:             # <<<<<<<<<<<<<<
     *                         vx = mat[i, xi] - meanx
     *                         vy = mat[i, yi] - meany
     */
              __pyx_t_35 = __pyx_v_i;
              __pyx_t_36 = __pyx_v_xi;
              __pyx_t_25 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
              if (__pyx_t_25) {
                __pyx_t_37 = __pyx_v_i;
                __pyx_t_38 = __pyx_v_yi;
                __pyx_t_9 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
                __pyx_t_8 = __pyx_t_9;
              } else {
                __pyx_t_8 = __pyx_t_25;
              }
              if (__pyx_t_8) {

     984:                         vx = mat[i, xi] - meanx

                /* "pandas/algos.pyx":984
     *                 for i in range(N):
     *                     if mask[i, xi] and mask[i, yi]:
     *                         vx = mat[i, xi] - meanx             # <<<<<<<<<<<<<<
     *                         vy = mat[i, yi] - meany
     *
     */
                __pyx_t_39 = __pyx_v_i;
                __pyx_t_40 = __pyx_v_xi;
                __pyx_v_vx = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mat.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_mat.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_mat.diminfo[1].strides)) - __pyx_v_meanx);

     985:                         vy = mat[i, yi] - meany

                /* "pandas/algos.pyx":985
     *                     if mask[i, xi] and mask[i, yi]:
     *                         vx = mat[i, xi] - meanx
     *                         vy = mat[i, yi] - meany             # <<<<<<<<<<<<<<
     *
     *                         sumx += vx * vy
     */
                __pyx_t_41 = __pyx_v_i;
                __pyx_t_42 = __pyx_v_yi;
                __pyx_v_vy = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mat.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_mat.diminfo[0].strides, __pyx_t_42, __pyx_pybuffernd_mat.diminfo[1].strides)) - __pyx_v_meany);

     986:

     987:                         sumx += vx * vy

                /* "pandas/algos.pyx":987
     *                         vy = mat[i, yi] - meany
     *
     *                         sumx += vx * vy             # <<<<<<<<<<<<<<
     *                         sumxx += vx * vx
     *                         sumyy += vy * vy
     */
                __pyx_v_sumx = (__pyx_v_sumx + (__pyx_v_vx * __pyx_v_vy));

     988:                         sumxx += vx * vx

                /* "pandas/algos.pyx":988
     *
     *                         sumx += vx * vy
     *                         sumxx += vx * vx             # <<<<<<<<<<<<<<
     *                         sumyy += vy * vy
     *
     */
                __pyx_v_sumxx = (__pyx_v_sumxx + (__pyx_v_vx * __pyx_v_vx));

     989:                         sumyy += vy * vy

                /* "pandas/algos.pyx":989
     *                         sumx += vx * vy
     *                         sumxx += vx * vx
     *                         sumyy += vy * vy             # <<<<<<<<<<<<<<
     *
     *                 divisor = (nobs - 1.0) if cov else sqrt(sumxx * sumyy)
     */
                __pyx_v_sumyy = (__pyx_v_sumyy + (__pyx_v_vy * __pyx_v_vy));
                goto __pyx_L16;
              }
              __pyx_L16:;
            }

     990:

     991:                 divisor = (nobs - 1.0) if cov else sqrt(sumxx * sumyy)

            /* "pandas/algos.pyx":991
     *                         sumyy += vy * vy
     *
     *                 divisor = (nobs - 1.0) if cov else sqrt(sumxx * sumyy)             # <<<<<<<<<<<<<<
     *
     *                 if divisor != 0:
     */
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_cov); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            if (__pyx_t_8) {
              __pyx_t_43 = (__pyx_v_nobs - 1.0);
            } else {
              __pyx_t_43 = sqrt((__pyx_v_sumxx * __pyx_v_sumyy));
            }
            __pyx_v_divisor = __pyx_t_43;

     992:

     993:                 if divisor != 0:

            /* "pandas/algos.pyx":993
     *                 divisor = (nobs - 1.0) if cov else sqrt(sumxx * sumyy)
     *
     *                 if divisor != 0:             # <<<<<<<<<<<<<<
     *                     result[xi, yi] = result[yi, xi] = sumx / divisor
     *                 else:
     */
            __pyx_t_8 = ((__pyx_v_divisor != 0.0) != 0);
            if (__pyx_t_8) {

     994:                     result[xi, yi] = result[yi, xi] = sumx / divisor

              /* "pandas/algos.pyx":994
     *
     *                 if divisor != 0:
     *                     result[xi, yi] = result[yi, xi] = sumx / divisor             # <<<<<<<<<<<<<<
     *                 else:
     *                     result[xi, yi] = result[yi, xi] = np.NaN
     */
              if (unlikely(__pyx_v_divisor == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_30 = (__pyx_v_sumx / __pyx_v_divisor);
              __pyx_t_33 = __pyx_v_xi;
              __pyx_t_34 = __pyx_v_yi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_30;
              __pyx_t_44 = __pyx_v_yi;
              __pyx_t_45 = __pyx_v_xi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_30;
              goto __pyx_L17;
            }
            /*else*/ {

     995:                 else:

     996:                     result[xi, yi] = result[yi, xi] = np.NaN

              /* "pandas/algos.pyx":996
     *                     result[xi, yi] = result[yi, xi] = sumx / divisor
     *                 else:
     *                     result[xi, yi] = result[yi, xi] = np.NaN             # <<<<<<<<<<<<<<
     *
     *     return result
     */
              __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NaN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_30 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_30 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __pyx_t_46 = __pyx_v_xi;
              __pyx_t_47 = __pyx_v_yi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_47, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_30;
              __pyx_t_30 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_30 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __pyx_t_48 = __pyx_v_yi;
              __pyx_t_49 = __pyx_v_xi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_49, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_30;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            }
            __pyx_L17:;
          }
          __pyx_L13:;
        }
      }

     997:

     998:     return result

      /* "pandas/algos.pyx":998
     *                     result[xi, yi] = result[yi, xi] = np.NaN
     *
     *     return result             # <<<<<<<<<<<<<<
     *
     * #----------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      __pyx_r = ((PyObject *)__pyx_v_result);
      goto __pyx_L0;

     999:

     1000: #----------------------------------------------------------------------

     1001: # Pairwise Spearman correlation

     1002:

     1003: @cython.boundscheck(False)

     1004: @cython.wraparound(False)

     1005: def nancorr_spearman(ndarray[float64_t, ndim=2] mat, Py_ssize_t minp=1):

    /* "pandas/algos.pyx":1005
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr_spearman(ndarray[float64_t, ndim=2] mat, Py_ssize_t minp=1):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_31nancorr_spearman(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_31nancorr_spearman = {__Pyx_NAMESTR("nancorr_spearman"), (PyCFunction)__pyx_pw_6pandas_5algos_31nancorr_spearman, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_31nancorr_spearman(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_mat = 0;
      Py_ssize_t __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("nancorr_spearman (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mat,&__pyx_n_s_minp,0};
        PyObject* values[2] = {0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp);
              if (value) { values[1] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nancorr_spearman") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_mat = ((PyArrayObject *)values[0]);
        if (values[1]) {
          __pyx_v_minp = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_minp == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        } else {
          __pyx_v_minp = ((Py_ssize_t)1);
        }
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("nancorr_spearman", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.nancorr_spearman", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mat), __pyx_ptype_5numpy_ndarray, 1, "mat", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_30nancorr_spearman(__pyx_self, __pyx_v_mat, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_30nancorr_spearman(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_mat, Py_ssize_t __pyx_v_minp) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_xi;
      Py_ssize_t __pyx_v_yi;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      PyArrayObject *__pyx_v_result = 0;
      PyArrayObject *__pyx_v_maskedx = 0;
      PyArrayObject *__pyx_v_maskedy = 0;
      PyArrayObject *__pyx_v_mask = 0;
      __pyx_t_5numpy_int64_t __pyx_v_nobs;
      __pyx_t_5numpy_float64_t __pyx_v_vx;
      __pyx_t_5numpy_float64_t __pyx_v_vy;
      __pyx_t_5numpy_float64_t __pyx_v_sumx;
      __pyx_t_5numpy_float64_t __pyx_v_sumxx;
      __pyx_t_5numpy_float64_t __pyx_v_sumyy;
      __pyx_t_5numpy_float64_t __pyx_v_mean;
      __pyx_t_5numpy_float64_t __pyx_v_divisor;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_mask;
      __Pyx_Buffer __pyx_pybuffer_mask;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_maskedx;
      __Pyx_Buffer __pyx_pybuffer_maskedx;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_maskedy;
      __Pyx_Buffer __pyx_pybuffer_maskedy;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_mat;
      __Pyx_Buffer __pyx_pybuffer_mat;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("nancorr_spearman", 0);
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_maskedx.pybuffer.buf = NULL;
      __pyx_pybuffer_maskedx.refcount = 0;
      __pyx_pybuffernd_maskedx.data = NULL;
      __pyx_pybuffernd_maskedx.rcbuffer = &__pyx_pybuffer_maskedx;
      __pyx_pybuffer_maskedy.pybuffer.buf = NULL;
      __pyx_pybuffer_maskedy.refcount = 0;
      __pyx_pybuffernd_maskedy.data = NULL;
      __pyx_pybuffernd_maskedy.rcbuffer = &__pyx_pybuffer_maskedy;
      __pyx_pybuffer_mask.pybuffer.buf = NULL;
      __pyx_pybuffer_mask.refcount = 0;
      __pyx_pybuffernd_mask.data = NULL;
      __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask;
      __pyx_pybuffer_mat.pybuffer.buf = NULL;
      __pyx_pybuffer_mat.refcount = 0;
      __pyx_pybuffernd_mat.data = NULL;
      __pyx_pybuffernd_mat.rcbuffer = &__pyx_pybuffer_mat;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mat.rcbuffer->pybuffer, (PyObject*)__pyx_v_mat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_mat.diminfo[0].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mat.diminfo[0].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mat.diminfo[1].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mat.diminfo[1].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[1];

      /* "pandas/algos.pyx":1005
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr_spearman(ndarray[float64_t, ndim=2] mat, Py_ssize_t minp=1):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_8);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.nancorr_spearman", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_result);
      __Pyx_XDECREF((PyObject *)__pyx_v_maskedx);
      __Pyx_XDECREF((PyObject *)__pyx_v_maskedy);
      __Pyx_XDECREF((PyObject *)__pyx_v_mask);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1005
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr_spearman(ndarray[float64_t, ndim=2] mat, Py_ssize_t minp=1):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */
      __pyx_tuple__246 = PyTuple_Pack(20, __pyx_n_s_mat, __pyx_n_s_minp, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_xi, __pyx_n_s_yi, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_result, __pyx_n_s_maskedx, __pyx_n_s_maskedy, __pyx_n_s_mask, __pyx_n_s_nobs, __pyx_n_s_vx, __pyx_n_s_vy, __pyx_n_s_sumx, __pyx_n_s_sumxx, __pyx_n_s_sumyy, __pyx_n_s_mean, __pyx_n_s_divisor); if (unlikely(!__pyx_tuple__246)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__246);
      __Pyx_GIVEREF(__pyx_tuple__246);

      /* "pandas/algos.pyx":1005
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def nancorr_spearman(ndarray[float64_t, ndim=2] mat, Py_ssize_t minp=1):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, j, xi, yi, N, K
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_31nancorr_spearman, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_nancorr_spearman, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__247 = (PyObject*)__Pyx_PyCode_New(2, 0, 20, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__246, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_nancorr_spearman, 1005, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__247)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1006:     cdef:

     1007:         Py_ssize_t i, j, xi, yi, N, K

     1008:         ndarray[float64_t, ndim=2] result

     1009:         ndarray[float64_t, ndim=1] maskedx

     1010:         ndarray[float64_t, ndim=1] maskedy

     1011:         ndarray[uint8_t, ndim=2] mask

     1012:         int64_t nobs = 0

      /* "pandas/algos.pyx":1012
     *         ndarray[float64_t, ndim=1] maskedy
     *         ndarray[uint8_t, ndim=2] mask
     *         int64_t nobs = 0             # <<<<<<<<<<<<<<
     *         float64_t vx, vy, sumx, sumxx, sumyy, mean, divisor
     *
     */
      __pyx_v_nobs = 0;

     1013:         float64_t vx, vy, sumx, sumxx, sumyy, mean, divisor

     1014:

     1015:     N, K = (<object> mat).shape

      /* "pandas/algos.pyx":1015
     *         float64_t vx, vy, sumx, sumxx, sumyy, mean, divisor
     *
     *     N, K = (<object> mat).shape             # <<<<<<<<<<<<<<
     *
     *     result = np.empty((K, K), dtype=np.float64)
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mat), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_6;
      __pyx_v_K = __pyx_t_7;

     1016:

     1017:     result = np.empty((K, K), dtype=np.float64)

      /* "pandas/algos.pyx":1017
     *     N, K = (<object> mat).shape
     *
     *     result = np.empty((K, K), dtype=np.float64)             # <<<<<<<<<<<<<<
     *     mask = np.isfinite(mat).view(np.uint8)
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_K); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_K); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_10 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_9 = 0;
      __pyx_v_result = ((PyArrayObject *)__pyx_t_8);
      __pyx_t_8 = 0;

     1018:     mask = np.isfinite(mat).view(np.uint8)

      /* "pandas/algos.pyx":1018
     *
     *     result = np.empty((K, K), dtype=np.float64)
     *     mask = np.isfinite(mat).view(np.uint8)             # <<<<<<<<<<<<<<
     *
     *     for xi in range(K):
     */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_isfinite); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(((PyObject *)__pyx_v_mat));
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_mat));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mat));
      __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_view); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_8, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
        __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_10 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
          }
        }
        __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_mask = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

     1019:

     1020:     for xi in range(K):

      /* "pandas/algos.pyx":1020
     *     mask = np.isfinite(mat).view(np.uint8)
     *
     *     for xi in range(K):             # <<<<<<<<<<<<<<
     *         for yi in range(xi + 1):
     *             nobs = 0
     */
      __pyx_t_7 = __pyx_v_K;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6+=1) {
        __pyx_v_xi = __pyx_t_6;

     1021:         for yi in range(xi + 1):

        /* "pandas/algos.pyx":1021
     *
     *     for xi in range(K):
     *         for yi in range(xi + 1):             # <<<<<<<<<<<<<<
     *             nobs = 0
     *             for i in range(N):
     */
        __pyx_t_15 = (__pyx_v_xi + 1);
        for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
          __pyx_v_yi = __pyx_t_16;

     1022:             nobs = 0

          /* "pandas/algos.pyx":1022
     *     for xi in range(K):
     *         for yi in range(xi + 1):
     *             nobs = 0             # <<<<<<<<<<<<<<
     *             for i in range(N):
     *                 if mask[i, xi] and mask[i, yi]:
     */
          __pyx_v_nobs = 0;

     1023:             for i in range(N):

          /* "pandas/algos.pyx":1023
     *         for yi in range(xi + 1):
     *             nobs = 0
     *             for i in range(N):             # <<<<<<<<<<<<<<
     *                 if mask[i, xi] and mask[i, yi]:
     *                     nobs += 1
     */
          __pyx_t_17 = __pyx_v_N;
          for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
            __pyx_v_i = __pyx_t_18;

     1024:                 if mask[i, xi] and mask[i, yi]:

            /* "pandas/algos.pyx":1024
     *             nobs = 0
     *             for i in range(N):
     *                 if mask[i, xi] and mask[i, yi]:             # <<<<<<<<<<<<<<
     *                     nobs += 1
     *
     */
            __pyx_t_19 = __pyx_v_i;
            __pyx_t_20 = __pyx_v_xi;
            __pyx_t_21 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
            if (__pyx_t_21) {
              __pyx_t_22 = __pyx_v_i;
              __pyx_t_23 = __pyx_v_yi;
              __pyx_t_24 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
              __pyx_t_25 = __pyx_t_24;
            } else {
              __pyx_t_25 = __pyx_t_21;
            }
            if (__pyx_t_25) {

     1025:                     nobs += 1

              /* "pandas/algos.pyx":1025
     *             for i in range(N):
     *                 if mask[i, xi] and mask[i, yi]:
     *                     nobs += 1             # <<<<<<<<<<<<<<
     *
     *             if nobs < minp:
     */
              __pyx_v_nobs = (__pyx_v_nobs + 1);
              goto __pyx_L11;
            }
            __pyx_L11:;
          }

     1026:

     1027:             if nobs < minp:

          /* "pandas/algos.pyx":1027
     *                     nobs += 1
     *
     *             if nobs < minp:             # <<<<<<<<<<<<<<
     *                 result[xi, yi] = result[yi, xi] = np.NaN
     *             else:
     */
          __pyx_t_25 = ((__pyx_v_nobs < __pyx_v_minp) != 0);
          if (__pyx_t_25) {

     1028:                 result[xi, yi] = result[yi, xi] = np.NaN

            /* "pandas/algos.pyx":1028
     *
     *             if nobs < minp:
     *                 result[xi, yi] = result[yi, xi] = np.NaN             # <<<<<<<<<<<<<<
     *             else:
     *                 maskedx = np.empty(nobs, dtype=np.float64)
     */
            __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NaN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_26 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_17 = __pyx_v_xi;
            __pyx_t_18 = __pyx_v_yi;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_26;
            __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_26 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_27 = __pyx_v_yi;
            __pyx_t_28 = __pyx_v_xi;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_26;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            goto __pyx_L12;
          }
          /*else*/ {

     1029:             else:

     1030:                 maskedx = np.empty(nobs, dtype=np.float64)

            /* "pandas/algos.pyx":1030
     *                 result[xi, yi] = result[yi, xi] = np.NaN
     *             else:
     *                 maskedx = np.empty(nobs, dtype=np.float64)             # <<<<<<<<<<<<<<
     *                 maskedy = np.empty(nobs, dtype=np.float64)
     *                 j = 0
     */
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_nobs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_8);
            PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            __pyx_t_2 = 0;
            __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_29 = ((PyArrayObject *)__pyx_t_1);
            {
              __Pyx_BufFmt_StackElem __pyx_stack[1];
              __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer);
              __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
              if (unlikely(__pyx_t_10 < 0)) {
                PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
                if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer, (PyObject*)__pyx_v_maskedx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
                  Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
                  __Pyx_RaiseBufferFallbackError();
                } else {
                  PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
                }
              }
              __pyx_pybuffernd_maskedx.diminfo[0].strides = __pyx_pybuffernd_maskedx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_maskedx.diminfo[0].shape = __pyx_pybuffernd_maskedx.rcbuffer->pybuffer.shape[0];
              if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_29 = 0;
            __Pyx_XDECREF_SET(__pyx_v_maskedx, ((PyArrayObject *)__pyx_t_1));
            __pyx_t_1 = 0;

     1031:                 maskedy = np.empty(nobs, dtype=np.float64)

            /* "pandas/algos.pyx":1031
     *             else:
     *                 maskedx = np.empty(nobs, dtype=np.float64)
     *                 maskedy = np.empty(nobs, dtype=np.float64)             # <<<<<<<<<<<<<<
     *                 j = 0
     *                 for i in range(N):
     */
            __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_nobs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_8);
            PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;
            __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_30 = ((PyArrayObject *)__pyx_t_3);
            {
              __Pyx_BufFmt_StackElem __pyx_stack[1];
              __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer);
              __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
              if (unlikely(__pyx_t_10 < 0)) {
                PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
                if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer, (PyObject*)__pyx_v_maskedy, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
                  Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
                  __Pyx_RaiseBufferFallbackError();
                } else {
                  PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
                }
              }
              __pyx_pybuffernd_maskedy.diminfo[0].strides = __pyx_pybuffernd_maskedy.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_maskedy.diminfo[0].shape = __pyx_pybuffernd_maskedy.rcbuffer->pybuffer.shape[0];
              if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_30 = 0;
            __Pyx_XDECREF_SET(__pyx_v_maskedy, ((PyArrayObject *)__pyx_t_3));
            __pyx_t_3 = 0;

     1032:                 j = 0

            /* "pandas/algos.pyx":1032
     *                 maskedx = np.empty(nobs, dtype=np.float64)
     *                 maskedy = np.empty(nobs, dtype=np.float64)
     *                 j = 0             # <<<<<<<<<<<<<<
     *                 for i in range(N):
     *                     if mask[i, xi] and mask[i, yi]:
     */
            __pyx_v_j = 0;

     1033:                 for i in range(N):

            /* "pandas/algos.pyx":1033
     *                 maskedy = np.empty(nobs, dtype=np.float64)
     *                 j = 0
     *                 for i in range(N):             # <<<<<<<<<<<<<<
     *                     if mask[i, xi] and mask[i, yi]:
     *                         maskedx[j] = mat[i, xi]
     */
            __pyx_t_31 = __pyx_v_N;
            for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) {
              __pyx_v_i = __pyx_t_32;

     1034:                     if mask[i, xi] and mask[i, yi]:

              /* "pandas/algos.pyx":1034
     *                 j = 0
     *                 for i in range(N):
     *                     if mask[i, xi] and mask[i, yi]:             # <<<<<<<<<<<<<<
     *                         maskedx[j] = mat[i, xi]
     *                         maskedy[j] = mat[i, yi]
     */
              __pyx_t_33 = __pyx_v_i;
              __pyx_t_34 = __pyx_v_xi;
              __pyx_t_25 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
              if (__pyx_t_25) {
                __pyx_t_35 = __pyx_v_i;
                __pyx_t_36 = __pyx_v_yi;
                __pyx_t_21 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_uint8_t *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_mask.diminfo[1].strides)) != 0);
                __pyx_t_24 = __pyx_t_21;
              } else {
                __pyx_t_24 = __pyx_t_25;
              }
              if (__pyx_t_24) {

     1035:                         maskedx[j] = mat[i, xi]

                /* "pandas/algos.pyx":1035
     *                 for i in range(N):
     *                     if mask[i, xi] and mask[i, yi]:
     *                         maskedx[j] = mat[i, xi]             # <<<<<<<<<<<<<<
     *                         maskedy[j] = mat[i, yi]
     *                         j += 1
     */
                __pyx_t_37 = __pyx_v_i;
                __pyx_t_38 = __pyx_v_xi;
                __pyx_t_39 = __pyx_v_j;
                *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_maskedx.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_maskedx.diminfo[0].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mat.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_mat.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_mat.diminfo[1].strides));

     1036:                         maskedy[j] = mat[i, yi]

                /* "pandas/algos.pyx":1036
     *                     if mask[i, xi] and mask[i, yi]:
     *                         maskedx[j] = mat[i, xi]
     *                         maskedy[j] = mat[i, yi]             # <<<<<<<<<<<<<<
     *                         j += 1
     *                 maskedx = rank_1d_float64(maskedx)
     */
                __pyx_t_40 = __pyx_v_i;
                __pyx_t_41 = __pyx_v_yi;
                __pyx_t_42 = __pyx_v_j;
                *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_maskedy.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_maskedy.diminfo[0].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mat.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_mat.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_mat.diminfo[1].strides));

     1037:                         j += 1

                /* "pandas/algos.pyx":1037
     *                         maskedx[j] = mat[i, xi]
     *                         maskedy[j] = mat[i, yi]
     *                         j += 1             # <<<<<<<<<<<<<<
     *                 maskedx = rank_1d_float64(maskedx)
     *                 maskedy = rank_1d_float64(maskedy)
     */
                __pyx_v_j = (__pyx_v_j + 1);
                goto __pyx_L15;
              }
              __pyx_L15:;
            }

     1038:                 maskedx = rank_1d_float64(maskedx)

            /* "pandas/algos.pyx":1038
     *                         maskedy[j] = mat[i, yi]
     *                         j += 1
     *                 maskedx = rank_1d_float64(maskedx)             # <<<<<<<<<<<<<<
     *                 maskedy = rank_1d_float64(maskedy)
     *
     */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_rank_1d_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_INCREF(((PyObject *)__pyx_v_maskedx));
            PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_maskedx));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_maskedx));
            __pyx_t_8 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_29 = ((PyArrayObject *)__pyx_t_8);
            {
              __Pyx_BufFmt_StackElem __pyx_stack[1];
              __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer);
              __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
              if (unlikely(__pyx_t_10 < 0)) {
                PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
                if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedx.rcbuffer->pybuffer, (PyObject*)__pyx_v_maskedx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
                  Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
                  __Pyx_RaiseBufferFallbackError();
                } else {
                  PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
                }
              }
              __pyx_pybuffernd_maskedx.diminfo[0].strides = __pyx_pybuffernd_maskedx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_maskedx.diminfo[0].shape = __pyx_pybuffernd_maskedx.rcbuffer->pybuffer.shape[0];
              if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_29 = 0;
            __Pyx_DECREF_SET(__pyx_v_maskedx, ((PyArrayObject *)__pyx_t_8));
            __pyx_t_8 = 0;

     1039:                 maskedy = rank_1d_float64(maskedy)

            /* "pandas/algos.pyx":1039
     *                         j += 1
     *                 maskedx = rank_1d_float64(maskedx)
     *                 maskedy = rank_1d_float64(maskedy)             # <<<<<<<<<<<<<<
     *
     *                 mean = (nobs + 1) / 2.
     */
            __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_rank_1d_float64); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_INCREF(((PyObject *)__pyx_v_maskedy));
            PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_maskedy));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_maskedy));
            __pyx_t_3 = PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_30 = ((PyArrayObject *)__pyx_t_3);
            {
              __Pyx_BufFmt_StackElem __pyx_stack[1];
              __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer);
              __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
              if (unlikely(__pyx_t_10 < 0)) {
                PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
                if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maskedy.rcbuffer->pybuffer, (PyObject*)__pyx_v_maskedy, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
                  Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
                  __Pyx_RaiseBufferFallbackError();
                } else {
                  PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
                }
              }
              __pyx_pybuffernd_maskedy.diminfo[0].strides = __pyx_pybuffernd_maskedy.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_maskedy.diminfo[0].shape = __pyx_pybuffernd_maskedy.rcbuffer->pybuffer.shape[0];
              if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_30 = 0;
            __Pyx_DECREF_SET(__pyx_v_maskedy, ((PyArrayObject *)__pyx_t_3));
            __pyx_t_3 = 0;

     1040:

     1041:                 mean = (nobs + 1) / 2.

            /* "pandas/algos.pyx":1041
     *                 maskedy = rank_1d_float64(maskedy)
     *
     *                 mean = (nobs + 1) / 2.             # <<<<<<<<<<<<<<
     *
     *                 # now the cov numerator
     */
            __pyx_v_mean = ((__pyx_v_nobs + 1) / 2.);

     1042:

     1043:                 # now the cov numerator

     1044:                 sumx = sumxx = sumyy = 0

            /* "pandas/algos.pyx":1044
     *
     *                 # now the cov numerator
     *                 sumx = sumxx = sumyy = 0             # <<<<<<<<<<<<<<
     *
     *                 for i in range(nobs):
     */
            __pyx_v_sumx = 0;
            __pyx_v_sumxx = 0;
            __pyx_v_sumyy = 0;

     1045:

     1046:                 for i in range(nobs):

            /* "pandas/algos.pyx":1046
     *                 sumx = sumxx = sumyy = 0
     *
     *                 for i in range(nobs):             # <<<<<<<<<<<<<<
     *                     vx = maskedx[i] - mean
     *                     vy = maskedy[i] - mean
     */
            __pyx_t_43 = __pyx_v_nobs;
            for (__pyx_t_31 = 0; __pyx_t_31 < __pyx_t_43; __pyx_t_31+=1) {
              __pyx_v_i = __pyx_t_31;

     1047:                     vx = maskedx[i] - mean

              /* "pandas/algos.pyx":1047
     *
     *                 for i in range(nobs):
     *                     vx = maskedx[i] - mean             # <<<<<<<<<<<<<<
     *                     vy = maskedy[i] - mean
     *
     */
              __pyx_t_32 = __pyx_v_i;
              __pyx_v_vx = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_maskedx.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_maskedx.diminfo[0].strides)) - __pyx_v_mean);

     1048:                     vy = maskedy[i] - mean

              /* "pandas/algos.pyx":1048
     *                 for i in range(nobs):
     *                     vx = maskedx[i] - mean
     *                     vy = maskedy[i] - mean             # <<<<<<<<<<<<<<
     *
     *                     sumx += vx * vy
     */
              __pyx_t_44 = __pyx_v_i;
              __pyx_v_vy = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_maskedy.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_maskedy.diminfo[0].strides)) - __pyx_v_mean);

     1049:

     1050:                     sumx += vx * vy

              /* "pandas/algos.pyx":1050
     *                     vy = maskedy[i] - mean
     *
     *                     sumx += vx * vy             # <<<<<<<<<<<<<<
     *                     sumxx += vx * vx
     *                     sumyy += vy * vy
     */
              __pyx_v_sumx = (__pyx_v_sumx + (__pyx_v_vx * __pyx_v_vy));

     1051:                     sumxx += vx * vx

              /* "pandas/algos.pyx":1051
     *
     *                     sumx += vx * vy
     *                     sumxx += vx * vx             # <<<<<<<<<<<<<<
     *                     sumyy += vy * vy
     *
     */
              __pyx_v_sumxx = (__pyx_v_sumxx + (__pyx_v_vx * __pyx_v_vx));

     1052:                     sumyy += vy * vy

              /* "pandas/algos.pyx":1052
     *                     sumx += vx * vy
     *                     sumxx += vx * vx
     *                     sumyy += vy * vy             # <<<<<<<<<<<<<<
     *
     *                 divisor = sqrt(sumxx * sumyy)
     */
              __pyx_v_sumyy = (__pyx_v_sumyy + (__pyx_v_vy * __pyx_v_vy));
            }

     1053:

     1054:                 divisor = sqrt(sumxx * sumyy)

            /* "pandas/algos.pyx":1054
     *                     sumyy += vy * vy
     *
     *                 divisor = sqrt(sumxx * sumyy)             # <<<<<<<<<<<<<<
     *
     *                 if divisor != 0:
     */
            __pyx_v_divisor = sqrt((__pyx_v_sumxx * __pyx_v_sumyy));

     1055:

     1056:                 if divisor != 0:

            /* "pandas/algos.pyx":1056
     *                 divisor = sqrt(sumxx * sumyy)
     *
     *                 if divisor != 0:             # <<<<<<<<<<<<<<
     *                     result[xi, yi] = result[yi, xi] = sumx / divisor
     *                 else:
     */
            __pyx_t_24 = ((__pyx_v_divisor != 0.0) != 0);
            if (__pyx_t_24) {

     1057:                     result[xi, yi] = result[yi, xi] = sumx / divisor

              /* "pandas/algos.pyx":1057
     *
     *                 if divisor != 0:
     *                     result[xi, yi] = result[yi, xi] = sumx / divisor             # <<<<<<<<<<<<<<
     *                 else:
     *                     result[xi, yi] = result[yi, xi] = np.NaN
     */
              if (unlikely(__pyx_v_divisor == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_26 = (__pyx_v_sumx / __pyx_v_divisor);
              __pyx_t_31 = __pyx_v_xi;
              __pyx_t_45 = __pyx_v_yi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_26;
              __pyx_t_46 = __pyx_v_yi;
              __pyx_t_47 = __pyx_v_xi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_47, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_26;
              goto __pyx_L18;
            }
            /*else*/ {

     1058:                 else:

     1059:                     result[xi, yi] = result[yi, xi] = np.NaN

              /* "pandas/algos.pyx":1059
     *                     result[xi, yi] = result[yi, xi] = sumx / divisor
     *                 else:
     *                     result[xi, yi] = result[yi, xi] = np.NaN             # <<<<<<<<<<<<<<
     *
     *     return result
     */
              __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_NaN); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_26 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __pyx_t_48 = __pyx_v_xi;
              __pyx_t_49 = __pyx_v_yi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_49, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_26;
              __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_26 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __pyx_t_50 = __pyx_v_yi;
              __pyx_t_51 = __pyx_v_xi;
              *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_50, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_51, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_t_26;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            }
            __pyx_L18:;
          }
          __pyx_L12:;
        }
      }

     1060:

     1061:     return result

      /* "pandas/algos.pyx":1061
     *                     result[xi, yi] = result[yi, xi] = np.NaN
     *
     *     return result             # <<<<<<<<<<<<<<
     *
     * #----------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      __pyx_r = ((PyObject *)__pyx_v_result);
      goto __pyx_L0;

     1062:

     1063: #----------------------------------------------------------------------

     1064: # Rolling variance

     1065:

     1066: def roll_var(ndarray[double_t] input, int win, int minp, int ddof=1):

    /* "pandas/algos.pyx":1066
     * # Rolling variance
     *
     * def roll_var(ndarray[double_t] input, int win, int minp, int ddof=1):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0
     *     cdef Py_ssize_t i
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_33roll_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_33roll_var = {__Pyx_NAMESTR("roll_var"), (PyCFunction)__pyx_pw_6pandas_5algos_33roll_var, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_33roll_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      int __pyx_v_ddof;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_var (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,&__pyx_n_s_ddof,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_var", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_var", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
              if (value) { values[3] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_var") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        if (values[3]) {
          __pyx_v_ddof = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_ddof == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        } else {
          __pyx_v_ddof = ((int)1);
        }
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_var", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_var", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_32roll_var(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp, __pyx_v_ddof);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_32roll_var(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp, int __pyx_v_ddof) {
      double __pyx_v_val;
      double __pyx_v_prev;
      double __pyx_v_sum_x;
      double __pyx_v_sum_xx;
      double __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_var", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1066
     * # Rolling variance
     *
     * def roll_var(ndarray[double_t] input, int win, int minp, int ddof=1):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0
     *     cdef Py_ssize_t i
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_var", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1066
     * # Rolling variance
     *
     * def roll_var(ndarray[double_t] input, int win, int minp, int ddof=1):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0
     *     cdef Py_ssize_t i
     */
      __pyx_tuple__248 = PyTuple_Pack(12, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_ddof, __pyx_n_s_val, __pyx_n_s_prev, __pyx_n_s_sum_x, __pyx_n_s_sum_xx, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output); if (unlikely(!__pyx_tuple__248)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__248);
      __Pyx_GIVEREF(__pyx_tuple__248);

      /* "pandas/algos.pyx":1066
     * # Rolling variance
     *
     * def roll_var(ndarray[double_t] input, int win, int minp, int ddof=1):             # <<<<<<<<<<<<<<
     *     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0
     *     cdef Py_ssize_t i
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_33roll_var, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_var, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__249 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__248, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_var, 1066, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__249)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1067:     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0

      /* "pandas/algos.pyx":1067
     *
     * def roll_var(ndarray[double_t] input, int win, int minp, int ddof=1):
     *     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t i
     *     cdef Py_ssize_t N = len(input)
     */
      __pyx_v_sum_x = 0.0;
      __pyx_v_sum_xx = 0.0;
      __pyx_v_nobs = 0.0;

     1068:     cdef Py_ssize_t i

     1069:     cdef Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":1069
     *     cdef double val, prev, sum_x = 0, sum_xx = 0, nobs = 0
     *     cdef Py_ssize_t i
     *     cdef Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     1070:

     1071:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":1071
     *     cdef Py_ssize_t N = len(input)
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(win, minp, N)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1072:

     1073:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":1073
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     1074:

     1075:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":1075
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     1076:         val = input[i]

        /* "pandas/algos.pyx":1076
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_input.diminfo[0].strides));

     1077:

     1078:         # Not NaN

     1079:         if val == val:

        /* "pandas/algos.pyx":1079
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             sum_x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1080:             nobs += 1

          /* "pandas/algos.pyx":1080
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             sum_x += val
     *             sum_xx += val * val
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1.0);

     1081:             sum_x += val

          /* "pandas/algos.pyx":1081
     *         if val == val:
     *             nobs += 1
     *             sum_x += val             # <<<<<<<<<<<<<<
     *             sum_xx += val * val
     *
     */
          __pyx_v_sum_x = (__pyx_v_sum_x + __pyx_v_val);

     1082:             sum_xx += val * val

          /* "pandas/algos.pyx":1082
     *             nobs += 1
     *             sum_x += val
     *             sum_xx += val * val             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          __pyx_v_sum_xx = (__pyx_v_sum_xx + (__pyx_v_val * __pyx_v_val));
          goto __pyx_L5;
        }
        __pyx_L5:;

     1083:

     1084:         output[i] = NaN

        /* "pandas/algos.pyx":1084
     *             sum_xx += val * val
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1085:

     1086:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":1086
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     1087:         val = input[i]

        /* "pandas/algos.pyx":1087
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     1088:

     1089:         if val == val:

        /* "pandas/algos.pyx":1089
     *         val = input[i]
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             sum_x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1090:             nobs += 1

          /* "pandas/algos.pyx":1090
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             sum_x += val
     *             sum_xx += val * val
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1.0);

     1091:             sum_x += val

          /* "pandas/algos.pyx":1091
     *         if val == val:
     *             nobs += 1
     *             sum_x += val             # <<<<<<<<<<<<<<
     *             sum_xx += val * val
     *
     */
          __pyx_v_sum_x = (__pyx_v_sum_x + __pyx_v_val);

     1092:             sum_xx += val * val

          /* "pandas/algos.pyx":1092
     *             nobs += 1
     *             sum_x += val
     *             sum_xx += val * val             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
          __pyx_v_sum_xx = (__pyx_v_sum_xx + (__pyx_v_val * __pyx_v_val));
          goto __pyx_L8;
        }
        __pyx_L8:;

     1093:

     1094:         if i > win - 1:

        /* "pandas/algos.pyx":1094
     *             sum_xx += val * val
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *             if prev == prev:
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     1095:             prev = input[i - win]

          /* "pandas/algos.pyx":1095
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *             if prev == prev:
     *                 sum_x -= prev
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     1096:             if prev == prev:

          /* "pandas/algos.pyx":1096
     *         if i > win - 1:
     *             prev = input[i - win]
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 sum_x -= prev
     *                 sum_xx -= prev * prev
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     1097:                 sum_x -= prev

            /* "pandas/algos.pyx":1097
     *             prev = input[i - win]
     *             if prev == prev:
     *                 sum_x -= prev             # <<<<<<<<<<<<<<
     *                 sum_xx -= prev * prev
     *                 nobs -= 1
     */
            __pyx_v_sum_x = (__pyx_v_sum_x - __pyx_v_prev);

     1098:                 sum_xx -= prev * prev

            /* "pandas/algos.pyx":1098
     *             if prev == prev:
     *                 sum_x -= prev
     *                 sum_xx -= prev * prev             # <<<<<<<<<<<<<<
     *                 nobs -= 1
     *
     */
            __pyx_v_sum_xx = (__pyx_v_sum_xx - (__pyx_v_prev * __pyx_v_prev));

     1099:                 nobs -= 1

            /* "pandas/algos.pyx":1099
     *                 sum_x -= prev
     *                 sum_xx -= prev * prev
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1.0);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     1100:

     1101:         if nobs >= minp:

        /* "pandas/algos.pyx":1101
     *                 nobs -= 1
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             # pathological case
     *             if nobs == 1:
     */
        __pyx_t_10 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_10) {

     1102:             # pathological case

     1103:             if nobs == 1:

          /* "pandas/algos.pyx":1103
     *         if nobs >= minp:
     *             # pathological case
     *             if nobs == 1:             # <<<<<<<<<<<<<<
     *                 output[i] = 0
     *                 continue
     */
          __pyx_t_10 = ((__pyx_v_nobs == 1.0) != 0);
          if (__pyx_t_10) {

     1104:                 output[i] = 0

            /* "pandas/algos.pyx":1104
     *             # pathological case
     *             if nobs == 1:
     *                 output[i] = 0             # <<<<<<<<<<<<<<
     *                 continue
     *
     */
            __pyx_t_15 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_15 < 0) {
              __pyx_t_15 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_15 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_output.diminfo[0].strides) = 0.0;

     1105:                 continue

            /* "pandas/algos.pyx":1105
     *             if nobs == 1:
     *                 output[i] = 0
     *                 continue             # <<<<<<<<<<<<<<
     *
     *             val = (nobs * sum_xx - sum_x * sum_x) / (nobs * (nobs - ddof))
     */
            goto __pyx_L6_continue;
          }

     1106:

     1107:             val = (nobs * sum_xx - sum_x * sum_x) / (nobs * (nobs - ddof))

          /* "pandas/algos.pyx":1107
     *                 continue
     *
     *             val = (nobs * sum_xx - sum_x * sum_x) / (nobs * (nobs - ddof))             # <<<<<<<<<<<<<<
     *             if val < 0:
     *                 val = 0
     */
          __pyx_t_16 = ((__pyx_v_nobs * __pyx_v_sum_xx) - (__pyx_v_sum_x * __pyx_v_sum_x));
          __pyx_t_17 = (__pyx_v_nobs * (__pyx_v_nobs - __pyx_v_ddof));
          if (unlikely(__pyx_t_17 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_val = (__pyx_t_16 / __pyx_t_17);

     1108:             if val < 0:

          /* "pandas/algos.pyx":1108
     *
     *             val = (nobs * sum_xx - sum_x * sum_x) / (nobs * (nobs - ddof))
     *             if val < 0:             # <<<<<<<<<<<<<<
     *                 val = 0
     *
     */
          __pyx_t_10 = ((__pyx_v_val < 0.0) != 0);
          if (__pyx_t_10) {

     1109:                 val = 0

            /* "pandas/algos.pyx":1109
     *             val = (nobs * sum_xx - sum_x * sum_x) / (nobs * (nobs - ddof))
     *             if val < 0:
     *                 val = 0             # <<<<<<<<<<<<<<
     *
     *             output[i] = val
     */
            __pyx_v_val = 0.0;
            goto __pyx_L13;
          }
          __pyx_L13:;

     1110:

     1111:             output[i] = val

          /* "pandas/algos.pyx":1111
     *                 val = 0
     *
     *             output[i] = val             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
          __pyx_t_18 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_val;
          goto __pyx_L11;
        }
        /*else*/ {

     1112:         else:

     1113:             output[i] = NaN

          /* "pandas/algos.pyx":1113
     *             output[i] = val
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     return output
     */
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L11:;
        __pyx_L6_continue:;
      }

     1114:

     1115:     return output

      /* "pandas/algos.pyx":1115
     *             output[i] = NaN
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * #-------------------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1116:

     1117: #-------------------------------------------------------------------------------

     1118: # Rolling skewness

     1119:

     1120: def roll_skew(ndarray[double_t] input, int win, int minp):

    /* "pandas/algos.pyx":1120
     * # Rolling skewness
     *
     * def roll_skew(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_35roll_skew(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_35roll_skew = {__Pyx_NAMESTR("roll_skew"), (PyCFunction)__pyx_pw_6pandas_5algos_35roll_skew, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_35roll_skew(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_skew (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_skew", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_skew", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_skew") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_skew", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_skew", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_34roll_skew(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_34roll_skew(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      double __pyx_v_val;
      double __pyx_v_prev;
      double __pyx_v_x;
      double __pyx_v_xx;
      double __pyx_v_xxx;
      Py_ssize_t __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      double __pyx_v_A;
      double __pyx_v_B;
      double __pyx_v_C;
      double __pyx_v_R;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_skew", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1120
     * # Rolling skewness
     *
     * def roll_skew(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_skew", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1120
     * # Rolling skewness
     *
     * def roll_skew(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0
     */
      __pyx_tuple__250 = PyTuple_Pack(16, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_val, __pyx_n_s_prev, __pyx_n_s_x, __pyx_n_s_xx, __pyx_n_s_xxx, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output, __pyx_n_s_A, __pyx_n_s_B, __pyx_n_s_C, __pyx_n_s_R); if (unlikely(!__pyx_tuple__250)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__250);
      __Pyx_GIVEREF(__pyx_tuple__250);

      /* "pandas/algos.pyx":1120
     * # Rolling skewness
     *
     * def roll_skew(ndarray[double_t] input, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_35roll_skew, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_skew, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__251 = (PyObject*)__Pyx_PyCode_New(3, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__250, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_skew, 1120, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__251)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1121:     cdef double val, prev

     1122:     cdef double x = 0, xx = 0, xxx = 0

      /* "pandas/algos.pyx":1122
     * def roll_skew(ndarray[double_t] input, int win, int minp):
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t nobs = 0, i
     *     cdef Py_ssize_t N = len(input)
     */
      __pyx_v_x = 0.0;
      __pyx_v_xx = 0.0;
      __pyx_v_xxx = 0.0;

     1123:     cdef Py_ssize_t nobs = 0, i

      /* "pandas/algos.pyx":1123
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0
     *     cdef Py_ssize_t nobs = 0, i             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t N = len(input)
     *
     */
      __pyx_v_nobs = 0;

     1124:     cdef Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":1124
     *     cdef double x = 0, xx = 0, xxx = 0
     *     cdef Py_ssize_t nobs = 0, i
     *     cdef Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     1125:

     1126:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":1126
     *     cdef Py_ssize_t N = len(input)
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     # 3 components of the skewness equation
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1127:

     1128:     # 3 components of the skewness equation

     1129:     cdef double A, B, C, R

     1130:

     1131:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":1131
     *     cdef double A, B, C, R
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     1132:

     1133:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":1133
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     1134:         val = input[i]

        /* "pandas/algos.pyx":1134
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_input.diminfo[0].strides));

     1135:

     1136:         # Not NaN

     1137:         if val == val:

        /* "pandas/algos.pyx":1137
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1138:             nobs += 1

          /* "pandas/algos.pyx":1138
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             x += val
     *             xx += val * val
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1139:             x += val

          /* "pandas/algos.pyx":1139
     *         if val == val:
     *             nobs += 1
     *             x += val             # <<<<<<<<<<<<<<
     *             xx += val * val
     *             xxx += val * val * val
     */
          __pyx_v_x = (__pyx_v_x + __pyx_v_val);

     1140:             xx += val * val

          /* "pandas/algos.pyx":1140
     *             nobs += 1
     *             x += val
     *             xx += val * val             # <<<<<<<<<<<<<<
     *             xxx += val * val * val
     *
     */
          __pyx_v_xx = (__pyx_v_xx + (__pyx_v_val * __pyx_v_val));

     1141:             xxx += val * val * val

          /* "pandas/algos.pyx":1141
     *             x += val
     *             xx += val * val
     *             xxx += val * val * val             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          __pyx_v_xxx = (__pyx_v_xxx + ((__pyx_v_val * __pyx_v_val) * __pyx_v_val));
          goto __pyx_L5;
        }
        __pyx_L5:;

     1142:

     1143:         output[i] = NaN

        /* "pandas/algos.pyx":1143
     *             xxx += val * val * val
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1144:

     1145:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":1145
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     1146:         val = input[i]

        /* "pandas/algos.pyx":1146
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     1147:

     1148:         if val == val:

        /* "pandas/algos.pyx":1148
     *         val = input[i]
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1149:             nobs += 1

          /* "pandas/algos.pyx":1149
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             x += val
     *             xx += val * val
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1150:             x += val

          /* "pandas/algos.pyx":1150
     *         if val == val:
     *             nobs += 1
     *             x += val             # <<<<<<<<<<<<<<
     *             xx += val * val
     *             xxx += val * val * val
     */
          __pyx_v_x = (__pyx_v_x + __pyx_v_val);

     1151:             xx += val * val

          /* "pandas/algos.pyx":1151
     *             nobs += 1
     *             x += val
     *             xx += val * val             # <<<<<<<<<<<<<<
     *             xxx += val * val * val
     *
     */
          __pyx_v_xx = (__pyx_v_xx + (__pyx_v_val * __pyx_v_val));

     1152:             xxx += val * val * val

          /* "pandas/algos.pyx":1152
     *             x += val
     *             xx += val * val
     *             xxx += val * val * val             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
          __pyx_v_xxx = (__pyx_v_xxx + ((__pyx_v_val * __pyx_v_val) * __pyx_v_val));
          goto __pyx_L8;
        }
        __pyx_L8:;

     1153:

     1154:         if i > win - 1:

        /* "pandas/algos.pyx":1154
     *             xxx += val * val * val
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *             if prev == prev:
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     1155:             prev = input[i - win]

          /* "pandas/algos.pyx":1155
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *             if prev == prev:
     *                 x -= prev
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     1156:             if prev == prev:

          /* "pandas/algos.pyx":1156
     *         if i > win - 1:
     *             prev = input[i - win]
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 x -= prev
     *                 xx -= prev * prev
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     1157:                 x -= prev

            /* "pandas/algos.pyx":1157
     *             prev = input[i - win]
     *             if prev == prev:
     *                 x -= prev             # <<<<<<<<<<<<<<
     *                 xx -= prev * prev
     *                 xxx -= prev * prev * prev
     */
            __pyx_v_x = (__pyx_v_x - __pyx_v_prev);

     1158:                 xx -= prev * prev

            /* "pandas/algos.pyx":1158
     *             if prev == prev:
     *                 x -= prev
     *                 xx -= prev * prev             # <<<<<<<<<<<<<<
     *                 xxx -= prev * prev * prev
     *
     */
            __pyx_v_xx = (__pyx_v_xx - (__pyx_v_prev * __pyx_v_prev));

     1159:                 xxx -= prev * prev * prev

            /* "pandas/algos.pyx":1159
     *                 x -= prev
     *                 xx -= prev * prev
     *                 xxx -= prev * prev * prev             # <<<<<<<<<<<<<<
     *
     *                 nobs -= 1
     */
            __pyx_v_xxx = (__pyx_v_xxx - ((__pyx_v_prev * __pyx_v_prev) * __pyx_v_prev));

     1160:

     1161:                 nobs -= 1

            /* "pandas/algos.pyx":1161
     *                 xxx -= prev * prev * prev
     *
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     1162:

     1163:         if nobs >= minp:

        /* "pandas/algos.pyx":1163
     *                 nobs -= 1
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             A = x / nobs
     *             B = xx / nobs - A * A
     */
        __pyx_t_10 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_10) {

     1164:             A = x / nobs

          /* "pandas/algos.pyx":1164
     *
     *         if nobs >= minp:
     *             A = x / nobs             # <<<<<<<<<<<<<<
     *             B = xx / nobs - A * A
     *             C = xxx / nobs - A * A * A - 3 * A * B
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_A = (__pyx_v_x / __pyx_v_nobs);

     1165:             B = xx / nobs - A * A

          /* "pandas/algos.pyx":1165
     *         if nobs >= minp:
     *             A = x / nobs
     *             B = xx / nobs - A * A             # <<<<<<<<<<<<<<
     *             C = xxx / nobs - A * A * A - 3 * A * B
     *
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_B = ((__pyx_v_xx / __pyx_v_nobs) - (__pyx_v_A * __pyx_v_A));

     1166:             C = xxx / nobs - A * A * A - 3 * A * B

          /* "pandas/algos.pyx":1166
     *             A = x / nobs
     *             B = xx / nobs - A * A
     *             C = xxx / nobs - A * A * A - 3 * A * B             # <<<<<<<<<<<<<<
     *
     *             R = sqrt(B)
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_C = (((__pyx_v_xxx / __pyx_v_nobs) - ((__pyx_v_A * __pyx_v_A) * __pyx_v_A)) - ((3.0 * __pyx_v_A) * __pyx_v_B));

     1167:

     1168:             R = sqrt(B)

          /* "pandas/algos.pyx":1168
     *             C = xxx / nobs - A * A * A - 3 * A * B
     *
     *             R = sqrt(B)             # <<<<<<<<<<<<<<
     *
     *             if B == 0 or nobs < 3:
     */
          __pyx_v_R = sqrt(__pyx_v_B);

     1169:

     1170:             if B == 0 or nobs < 3:

          /* "pandas/algos.pyx":1170
     *             R = sqrt(B)
     *
     *             if B == 0 or nobs < 3:             # <<<<<<<<<<<<<<
     *                 output[i] = NaN
     *             else:
     */
          __pyx_t_10 = ((__pyx_v_B == 0.0) != 0);
          if (!__pyx_t_10) {
            __pyx_t_15 = ((__pyx_v_nobs < 3) != 0);
            __pyx_t_16 = __pyx_t_15;
          } else {
            __pyx_t_16 = __pyx_t_10;
          }
          if (__pyx_t_16) {

     1171:                 output[i] = NaN

            /* "pandas/algos.pyx":1171
     *
     *             if B == 0 or nobs < 3:
     *                 output[i] = NaN             # <<<<<<<<<<<<<<
     *             else:
     *                 output[i] = ((sqrt(nobs * (nobs - 1.)) * C) /
     */
            __pyx_t_17 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_17 < 0) {
              __pyx_t_17 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_17 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
            goto __pyx_L12;
          }
          /*else*/ {

     1172:             else:

     1173:                 output[i] = ((sqrt(nobs * (nobs - 1.)) * C) /

            /* "pandas/algos.pyx":1173
     *                 output[i] = NaN
     *             else:
     *                 output[i] = ((sqrt(nobs * (nobs - 1.)) * C) /             # <<<<<<<<<<<<<<
     *                              ((nobs-2) * R * R * R))
     *         else:
     */
            __pyx_t_18 = (sqrt((__pyx_v_nobs * (__pyx_v_nobs - 1.))) * __pyx_v_C);

            /* "pandas/algos.pyx":1173
     *                 output[i] = NaN
     *             else:
     *                 output[i] = ((sqrt(nobs * (nobs - 1.)) * C) /             # <<<<<<<<<<<<<<
     *                              ((nobs-2) * R * R * R))
     *         else:
     */
            if (unlikely(__pyx_t_19 == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "float division");
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_20 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_20 < 0) {
              __pyx_t_20 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_20 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_output.diminfo[0].strides) = (__pyx_t_18 / __pyx_t_19);
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        /*else*/ {

     1174:                              ((nobs-2) * R * R * R))

            /* "pandas/algos.pyx":1174
     *             else:
     *                 output[i] = ((sqrt(nobs * (nobs - 1.)) * C) /
     *                              ((nobs-2) * R * R * R))             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
            __pyx_t_19 = ((((__pyx_v_nobs - 2) * __pyx_v_R) * __pyx_v_R) * __pyx_v_R);

     1175:         else:

     1176:             output[i] = NaN

          /* "pandas/algos.pyx":1176
     *                              ((nobs-2) * R * R * R))
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     return output
     */
          __pyx_t_21 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_21 < 0) {
            __pyx_t_21 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_21 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L11:;
      }

     1177:

     1178:     return output

      /* "pandas/algos.pyx":1178
     *             output[i] = NaN
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * #-------------------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1179:

     1180: #-------------------------------------------------------------------------------

     1181: # Rolling kurtosis

     1182:

     1183:

     1184: def roll_kurt(ndarray[double_t] input,

    /* "pandas/algos.pyx":1184
     *
     *
     * def roll_kurt(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef double val, prev
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_37roll_kurt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_37roll_kurt = {__Pyx_NAMESTR("roll_kurt"), (PyCFunction)__pyx_pw_6pandas_5algos_37roll_kurt, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_37roll_kurt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_kurt (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_kurt", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_kurt", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_kurt") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_kurt", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_kurt", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_36roll_kurt(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_36roll_kurt(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      double __pyx_v_val;
      double __pyx_v_prev;
      double __pyx_v_x;
      double __pyx_v_xx;
      double __pyx_v_xxx;
      double __pyx_v_xxxx;
      Py_ssize_t __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      double __pyx_v_A;
      double __pyx_v_B;
      double __pyx_v_C;
      double __pyx_v_D;
      double __pyx_v_R;
      double __pyx_v_K;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_kurt", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1184
     *
     *
     * def roll_kurt(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef double val, prev
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_kurt", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1184
     *
     *
     * def roll_kurt(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef double val, prev
     */
      __pyx_tuple__252 = PyTuple_Pack(19, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_val, __pyx_n_s_prev, __pyx_n_s_x, __pyx_n_s_xx, __pyx_n_s_xxx, __pyx_n_s_xxxx, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output, __pyx_n_s_A, __pyx_n_s_B, __pyx_n_s_C, __pyx_n_s_D, __pyx_n_s_R, __pyx_n_s_K); if (unlikely(!__pyx_tuple__252)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__252);
      __Pyx_GIVEREF(__pyx_tuple__252);

      /* "pandas/algos.pyx":1184
     *
     *
     * def roll_kurt(ndarray[double_t] input,             # <<<<<<<<<<<<<<
     *                int win, int minp):
     *     cdef double val, prev
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_37roll_kurt, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_kurt, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__253 = (PyObject*)__Pyx_PyCode_New(3, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__252, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_kurt, 1184, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__253)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1185:                int win, int minp):

     1186:     cdef double val, prev

     1187:     cdef double x = 0, xx = 0, xxx = 0, xxxx = 0

      /* "pandas/algos.pyx":1187
     *                int win, int minp):
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0, xxxx = 0             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t nobs = 0, i
     *     cdef Py_ssize_t N = len(input)
     */
      __pyx_v_x = 0.0;
      __pyx_v_xx = 0.0;
      __pyx_v_xxx = 0.0;
      __pyx_v_xxxx = 0.0;

     1188:     cdef Py_ssize_t nobs = 0, i

      /* "pandas/algos.pyx":1188
     *     cdef double val, prev
     *     cdef double x = 0, xx = 0, xxx = 0, xxxx = 0
     *     cdef Py_ssize_t nobs = 0, i             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t N = len(input)
     *
     */
      __pyx_v_nobs = 0;

     1189:     cdef Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":1189
     *     cdef double x = 0, xx = 0, xxx = 0, xxxx = 0
     *     cdef Py_ssize_t nobs = 0, i
     *     cdef Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     1190:

     1191:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":1191
     *     cdef Py_ssize_t N = len(input)
     *
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     # 5 components of the kurtosis equation
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1192:

     1193:     # 5 components of the kurtosis equation

     1194:     cdef double A, B, C, D, R, K

     1195:

     1196:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":1196
     *     cdef double A, B, C, D, R, K
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     1197:

     1198:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":1198
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     1199:         val = input[i]

        /* "pandas/algos.pyx":1199
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_input.diminfo[0].strides));

     1200:

     1201:         # Not NaN

     1202:         if val == val:

        /* "pandas/algos.pyx":1202
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1203:             nobs += 1

          /* "pandas/algos.pyx":1203
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *
     *             # seriously don't ask me why this is faster
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1204:

     1205:             # seriously don't ask me why this is faster

     1206:             x += val

          /* "pandas/algos.pyx":1206
     *
     *             # seriously don't ask me why this is faster
     *             x += val             # <<<<<<<<<<<<<<
     *             xx += val * val
     *             xxx += val * val * val
     */
          __pyx_v_x = (__pyx_v_x + __pyx_v_val);

     1207:             xx += val * val

          /* "pandas/algos.pyx":1207
     *             # seriously don't ask me why this is faster
     *             x += val
     *             xx += val * val             # <<<<<<<<<<<<<<
     *             xxx += val * val * val
     *             xxxx += val * val * val * val
     */
          __pyx_v_xx = (__pyx_v_xx + (__pyx_v_val * __pyx_v_val));

     1208:             xxx += val * val * val

          /* "pandas/algos.pyx":1208
     *             x += val
     *             xx += val * val
     *             xxx += val * val * val             # <<<<<<<<<<<<<<
     *             xxxx += val * val * val * val
     *
     */
          __pyx_v_xxx = (__pyx_v_xxx + ((__pyx_v_val * __pyx_v_val) * __pyx_v_val));

     1209:             xxxx += val * val * val * val

          /* "pandas/algos.pyx":1209
     *             xx += val * val
     *             xxx += val * val * val
     *             xxxx += val * val * val * val             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          __pyx_v_xxxx = (__pyx_v_xxxx + (((__pyx_v_val * __pyx_v_val) * __pyx_v_val) * __pyx_v_val));
          goto __pyx_L5;
        }
        __pyx_L5:;

     1210:

     1211:         output[i] = NaN

        /* "pandas/algos.pyx":1211
     *             xxxx += val * val * val * val
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1212:

     1213:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":1213
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     1214:         val = input[i]

        /* "pandas/algos.pyx":1214
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     1215:

     1216:         if val == val:

        /* "pandas/algos.pyx":1216
     *         val = input[i]
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             x += val
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1217:             nobs += 1

          /* "pandas/algos.pyx":1217
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             x += val
     *             xx += val * val
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1218:             x += val

          /* "pandas/algos.pyx":1218
     *         if val == val:
     *             nobs += 1
     *             x += val             # <<<<<<<<<<<<<<
     *             xx += val * val
     *             xxx += val * val * val
     */
          __pyx_v_x = (__pyx_v_x + __pyx_v_val);

     1219:             xx += val * val

          /* "pandas/algos.pyx":1219
     *             nobs += 1
     *             x += val
     *             xx += val * val             # <<<<<<<<<<<<<<
     *             xxx += val * val * val
     *             xxxx += val * val * val * val
     */
          __pyx_v_xx = (__pyx_v_xx + (__pyx_v_val * __pyx_v_val));

     1220:             xxx += val * val * val

          /* "pandas/algos.pyx":1220
     *             x += val
     *             xx += val * val
     *             xxx += val * val * val             # <<<<<<<<<<<<<<
     *             xxxx += val * val * val * val
     *
     */
          __pyx_v_xxx = (__pyx_v_xxx + ((__pyx_v_val * __pyx_v_val) * __pyx_v_val));

     1221:             xxxx += val * val * val * val

          /* "pandas/algos.pyx":1221
     *             xx += val * val
     *             xxx += val * val * val
     *             xxxx += val * val * val * val             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
          __pyx_v_xxxx = (__pyx_v_xxxx + (((__pyx_v_val * __pyx_v_val) * __pyx_v_val) * __pyx_v_val));
          goto __pyx_L8;
        }
        __pyx_L8:;

     1222:

     1223:         if i > win - 1:

        /* "pandas/algos.pyx":1223
     *             xxxx += val * val * val * val
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *             if prev == prev:
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     1224:             prev = input[i - win]

          /* "pandas/algos.pyx":1224
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *             if prev == prev:
     *                 x -= prev
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     1225:             if prev == prev:

          /* "pandas/algos.pyx":1225
     *         if i > win - 1:
     *             prev = input[i - win]
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 x -= prev
     *                 xx -= prev * prev
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     1226:                 x -= prev

            /* "pandas/algos.pyx":1226
     *             prev = input[i - win]
     *             if prev == prev:
     *                 x -= prev             # <<<<<<<<<<<<<<
     *                 xx -= prev * prev
     *                 xxx -= prev * prev * prev
     */
            __pyx_v_x = (__pyx_v_x - __pyx_v_prev);

     1227:                 xx -= prev * prev

            /* "pandas/algos.pyx":1227
     *             if prev == prev:
     *                 x -= prev
     *                 xx -= prev * prev             # <<<<<<<<<<<<<<
     *                 xxx -= prev * prev * prev
     *                 xxxx -= prev * prev * prev * prev
     */
            __pyx_v_xx = (__pyx_v_xx - (__pyx_v_prev * __pyx_v_prev));

     1228:                 xxx -= prev * prev * prev

            /* "pandas/algos.pyx":1228
     *                 x -= prev
     *                 xx -= prev * prev
     *                 xxx -= prev * prev * prev             # <<<<<<<<<<<<<<
     *                 xxxx -= prev * prev * prev * prev
     *
     */
            __pyx_v_xxx = (__pyx_v_xxx - ((__pyx_v_prev * __pyx_v_prev) * __pyx_v_prev));

     1229:                 xxxx -= prev * prev * prev * prev

            /* "pandas/algos.pyx":1229
     *                 xx -= prev * prev
     *                 xxx -= prev * prev * prev
     *                 xxxx -= prev * prev * prev * prev             # <<<<<<<<<<<<<<
     *
     *                 nobs -= 1
     */
            __pyx_v_xxxx = (__pyx_v_xxxx - (((__pyx_v_prev * __pyx_v_prev) * __pyx_v_prev) * __pyx_v_prev));

     1230:

     1231:                 nobs -= 1

            /* "pandas/algos.pyx":1231
     *                 xxxx -= prev * prev * prev * prev
     *
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     1232:

     1233:         if nobs >= minp:

        /* "pandas/algos.pyx":1233
     *                 nobs -= 1
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             A = x / nobs
     *             R = A * A
     */
        __pyx_t_10 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_10) {

     1234:             A = x / nobs

          /* "pandas/algos.pyx":1234
     *
     *         if nobs >= minp:
     *             A = x / nobs             # <<<<<<<<<<<<<<
     *             R = A * A
     *             B = xx / nobs - R
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_A = (__pyx_v_x / __pyx_v_nobs);

     1235:             R = A * A

          /* "pandas/algos.pyx":1235
     *         if nobs >= minp:
     *             A = x / nobs
     *             R = A * A             # <<<<<<<<<<<<<<
     *             B = xx / nobs - R
     *             R = R * A
     */
          __pyx_v_R = (__pyx_v_A * __pyx_v_A);

     1236:             B = xx / nobs - R

          /* "pandas/algos.pyx":1236
     *             A = x / nobs
     *             R = A * A
     *             B = xx / nobs - R             # <<<<<<<<<<<<<<
     *             R = R * A
     *             C = xxx / nobs - R - 3 * A * B
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_B = ((__pyx_v_xx / __pyx_v_nobs) - __pyx_v_R);

     1237:             R = R * A

          /* "pandas/algos.pyx":1237
     *             R = A * A
     *             B = xx / nobs - R
     *             R = R * A             # <<<<<<<<<<<<<<
     *             C = xxx / nobs - R - 3 * A * B
     *             R = R * A
     */
          __pyx_v_R = (__pyx_v_R * __pyx_v_A);

     1238:             C = xxx / nobs - R - 3 * A * B

          /* "pandas/algos.pyx":1238
     *             B = xx / nobs - R
     *             R = R * A
     *             C = xxx / nobs - R - 3 * A * B             # <<<<<<<<<<<<<<
     *             R = R * A
     *             D = xxxx / nobs - R - 6*B*A*A - 4*C*A
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_C = (((__pyx_v_xxx / __pyx_v_nobs) - __pyx_v_R) - ((3.0 * __pyx_v_A) * __pyx_v_B));

     1239:             R = R * A

          /* "pandas/algos.pyx":1239
     *             R = R * A
     *             C = xxx / nobs - R - 3 * A * B
     *             R = R * A             # <<<<<<<<<<<<<<
     *             D = xxxx / nobs - R - 6*B*A*A - 4*C*A
     *
     */
          __pyx_v_R = (__pyx_v_R * __pyx_v_A);

     1240:             D = xxxx / nobs - R - 6*B*A*A - 4*C*A

          /* "pandas/algos.pyx":1240
     *             C = xxx / nobs - R - 3 * A * B
     *             R = R * A
     *             D = xxxx / nobs - R - 6*B*A*A - 4*C*A             # <<<<<<<<<<<<<<
     *
     *             if B == 0 or nobs < 4:
     */
          if (unlikely(__pyx_v_nobs == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_D = ((((__pyx_v_xxxx / __pyx_v_nobs) - __pyx_v_R) - (((6.0 * __pyx_v_B) * __pyx_v_A) * __pyx_v_A)) - ((4.0 * __pyx_v_C) * __pyx_v_A));

     1241:

     1242:             if B == 0 or nobs < 4:

          /* "pandas/algos.pyx":1242
     *             D = xxxx / nobs - R - 6*B*A*A - 4*C*A
     *
     *             if B == 0 or nobs < 4:             # <<<<<<<<<<<<<<
     *                 output[i] = NaN
     *
     */
          __pyx_t_10 = ((__pyx_v_B == 0.0) != 0);
          if (!__pyx_t_10) {
            __pyx_t_15 = ((__pyx_v_nobs < 4) != 0);
            __pyx_t_16 = __pyx_t_15;
          } else {
            __pyx_t_16 = __pyx_t_10;
          }
          if (__pyx_t_16) {

     1243:                 output[i] = NaN

            /* "pandas/algos.pyx":1243
     *
     *             if B == 0 or nobs < 4:
     *                 output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *             else:
     */
            __pyx_t_17 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_17 < 0) {
              __pyx_t_17 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_17 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
            goto __pyx_L12;
          }
          /*else*/ {

     1244:

     1245:             else:

     1246:                 K = (nobs * nobs - 1.)*D/(B*B) - 3*((nobs-1.)**2)

            /* "pandas/algos.pyx":1246
     *
     *             else:
     *                 K = (nobs * nobs - 1.)*D/(B*B) - 3*((nobs-1.)**2)             # <<<<<<<<<<<<<<
     *                 K = K / ((nobs - 2.)*(nobs-3.))
     *
     */
            __pyx_t_18 = (((__pyx_v_nobs * __pyx_v_nobs) - 1.) * __pyx_v_D);
            __pyx_t_19 = (__pyx_v_B * __pyx_v_B);
            if (unlikely(__pyx_t_19 == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "float division");
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_K = ((__pyx_t_18 / __pyx_t_19) - (3.0 * pow((__pyx_v_nobs - 1.), 2.0)));

     1247:                 K = K / ((nobs - 2.)*(nobs-3.))

            /* "pandas/algos.pyx":1247
     *             else:
     *                 K = (nobs * nobs - 1.)*D/(B*B) - 3*((nobs-1.)**2)
     *                 K = K / ((nobs - 2.)*(nobs-3.))             # <<<<<<<<<<<<<<
     *
     *                 output[i] = K
     */
            __pyx_t_19 = ((__pyx_v_nobs - 2.) * (__pyx_v_nobs - 3.));
            if (unlikely(__pyx_t_19 == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "float division");
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_K = (__pyx_v_K / __pyx_t_19);

     1248:

     1249:                 output[i] = K

            /* "pandas/algos.pyx":1249
     *                 K = K / ((nobs - 2.)*(nobs-3.))
     *
     *                 output[i] = K             # <<<<<<<<<<<<<<
     *
     *         else:
     */
            __pyx_t_20 = __pyx_v_i;
            __pyx_t_8 = -1;
            if (__pyx_t_20 < 0) {
              __pyx_t_20 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_20 < 0)) __pyx_t_8 = 0;
            } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
            if (unlikely(__pyx_t_8 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_8);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_K;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        /*else*/ {

     1250:

     1251:         else:

     1252:             output[i] = NaN

          /* "pandas/algos.pyx":1252
     *
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     return output
     */
          __pyx_t_21 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_21 < 0) {
            __pyx_t_21 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_21 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L11:;
      }

     1253:

     1254:     return output

      /* "pandas/algos.pyx":1254
     *             output[i] = NaN
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * #-------------------------------------------------------------------------------
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1255:

     1256: #-------------------------------------------------------------------------------

     1257: # Rolling median, min, max

     1258:

     1259: ctypedef double_t (* skiplist_f)(object sl, int n, int p)

    /* "pandas/algos.pyx":1259
     * # Rolling median, min, max
     *
     * ctypedef double_t (* skiplist_f)(object sl, int n, int p)             # <<<<<<<<<<<<<<
     *
     * cdef _roll_skiplist_op(ndarray arg, int win, int minp, skiplist_f op):
     */
    typedef __pyx_t_5numpy_double_t (*__pyx_t_6pandas_5algos_skiplist_f)(PyObject *, int, int);

     1260:

     1261: cdef _roll_skiplist_op(ndarray arg, int win, int minp, skiplist_f op):

    /* "pandas/algos.pyx":1261
     * ctypedef double_t (* skiplist_f)(object sl, int n, int p)
     *
     * cdef _roll_skiplist_op(ndarray arg, int win, int minp, skiplist_f op):             # <<<<<<<<<<<<<<
     *     cdef ndarray[double_t] input = arg
     *     cdef double val, prev, midpoint
     */

    static PyObject *__pyx_f_6pandas_5algos__roll_skiplist_op(PyArrayObject *__pyx_v_arg, int __pyx_v_win, int __pyx_v_minp, __pyx_t_6pandas_5algos_skiplist_f __pyx_v_op) {
      PyArrayObject *__pyx_v_input = 0;
      double __pyx_v_val;
      double __pyx_v_prev;
      struct __pyx_obj_6pandas_5algos_IndexableSkiplist *__pyx_v_skiplist = 0;
      Py_ssize_t __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_roll_skiplist_op", 0);
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;

      /* "pandas/algos.pyx":1261
     * ctypedef double_t (* skiplist_f)(object sl, int n, int p)
     *
     * cdef _roll_skiplist_op(ndarray arg, int win, int minp, skiplist_f op):             # <<<<<<<<<<<<<<
     *     cdef ndarray[double_t] input = arg
     *     cdef double val, prev, midpoint
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos._roll_skiplist_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_input);
      __Pyx_XDECREF((PyObject *)__pyx_v_skiplist);
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     1262:     cdef ndarray[double_t] input = arg

      /* "pandas/algos.pyx":1262
     *
     * cdef _roll_skiplist_op(ndarray arg, int win, int minp, skiplist_f op):
     *     cdef ndarray[double_t] input = arg             # <<<<<<<<<<<<<<
     *     cdef double val, prev, midpoint
     *     cdef IndexableSkiplist skiplist
     */
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_arg), &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_input = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_input.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];
        }
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_arg));
      __pyx_v_input = ((PyArrayObject *)__pyx_v_arg);

     1263:     cdef double val, prev, midpoint

     1264:     cdef IndexableSkiplist skiplist

     1265:     cdef Py_ssize_t nobs = 0, i

      /* "pandas/algos.pyx":1265
     *     cdef double val, prev, midpoint
     *     cdef IndexableSkiplist skiplist
     *     cdef Py_ssize_t nobs = 0, i             # <<<<<<<<<<<<<<
     *
     *     cdef Py_ssize_t N = len(input)
     */
      __pyx_v_nobs = 0;

     1266:

     1267:     cdef Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":1267
     *     cdef Py_ssize_t nobs = 0, i
     *
     *     cdef Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     1268:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":1268
     *
     *     cdef Py_ssize_t N = len(input)
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     skiplist = IndexableSkiplist(win)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1269:

     1270:     skiplist = IndexableSkiplist(win)

      /* "pandas/algos.pyx":1270
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     *     skiplist = IndexableSkiplist(win)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(win, minp, N)
     */
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6pandas_5algos_IndexableSkiplist)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_skiplist = ((struct __pyx_obj_6pandas_5algos_IndexableSkiplist *)__pyx_t_5);
      __pyx_t_5 = 0;

     1271:

     1272:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":1272
     *     skiplist = IndexableSkiplist(win)
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     1273:

     1274:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":1274
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     1275:         val = input[i]

        /* "pandas/algos.pyx":1275
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_input.diminfo[0].strides));

     1276:

     1277:         # Not NaN

     1278:         if val == val:

        /* "pandas/algos.pyx":1278
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             skiplist.insert(val)
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1279:             nobs += 1

          /* "pandas/algos.pyx":1279
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             skiplist.insert(val)
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1280:             skiplist.insert(val)

          /* "pandas/algos.pyx":1280
     *         if val == val:
     *             nobs += 1
     *             skiplist.insert(val)             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->insert(__pyx_v_skiplist, __pyx_v_val, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L5;
        }
        __pyx_L5:;

     1281:

     1282:         output[i] = NaN

        /* "pandas/algos.pyx":1282
     *             skiplist.insert(val)
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1283:

     1284:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":1284
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     1285:         val = input[i]

        /* "pandas/algos.pyx":1285
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     1286:

     1287:         if i > win - 1:

        /* "pandas/algos.pyx":1287
     *         val = input[i]
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     1288:             prev = input[i - win]

          /* "pandas/algos.pyx":1288
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *
     *             if prev == prev:
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     1289:

     1290:             if prev == prev:

          /* "pandas/algos.pyx":1290
     *             prev = input[i - win]
     *
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 skiplist.remove(prev)
     *                 nobs -= 1
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     1291:                 skiplist.remove(prev)

            /* "pandas/algos.pyx":1291
     *
     *             if prev == prev:
     *                 skiplist.remove(prev)             # <<<<<<<<<<<<<<
     *                 nobs -= 1
     *
     */
            __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->remove(__pyx_v_skiplist, __pyx_v_prev, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     1292:                 nobs -= 1

            /* "pandas/algos.pyx":1292
     *             if prev == prev:
     *                 skiplist.remove(prev)
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);
            goto __pyx_L9;
          }
          __pyx_L9:;
          goto __pyx_L8;
        }
        __pyx_L8:;

     1293:

     1294:         if val == val:

        /* "pandas/algos.pyx":1294
     *                 nobs -= 1
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             skiplist.insert(val)
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1295:             nobs += 1

          /* "pandas/algos.pyx":1295
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             skiplist.insert(val)
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1296:             skiplist.insert(val)

          /* "pandas/algos.pyx":1296
     *         if val == val:
     *             nobs += 1
     *             skiplist.insert(val)             # <<<<<<<<<<<<<<
     *
     *         output[i] = op(skiplist, nobs, minp)
     */
          __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->insert(__pyx_v_skiplist, __pyx_v_val, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;

     1297:

     1298:         output[i] = op(skiplist, nobs, minp)

        /* "pandas/algos.pyx":1298
     *             skiplist.insert(val)
     *
     *         output[i] = op(skiplist, nobs, minp)             # <<<<<<<<<<<<<<
     *
     *     return output
     */
        __pyx_t_15 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_15 < 0) {
          __pyx_t_15 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_15 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_op(((PyObject *)__pyx_v_skiplist), __pyx_v_nobs, __pyx_v_minp);
      }

     1299:

     1300:     return output

      /* "pandas/algos.pyx":1300
     *         output[i] = op(skiplist, nobs, minp)
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * from skiplist cimport *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1301:

     1302: from skiplist cimport *

     1303:

     1304: def roll_median_c(ndarray[float64_t] arg, int win, int minp):

    /* "pandas/algos.pyx":1304
     * from skiplist cimport *
     *
     * def roll_median_c(ndarray[float64_t] arg, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, res, prev
     *     cdef:
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_39roll_median_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_39roll_median_c = {__Pyx_NAMESTR("roll_median_c"), (PyCFunction)__pyx_pw_6pandas_5algos_39roll_median_c, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_39roll_median_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_arg = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_median_c (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arg,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arg)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_median_c", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_median_c", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_median_c") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_arg = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_median_c", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_median_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arg), __pyx_ptype_5numpy_ndarray, 1, "arg", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_38roll_median_c(__pyx_self, __pyx_v_arg, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_38roll_median_c(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arg, int __pyx_v_win, int __pyx_v_minp) {
      double __pyx_v_val;
      double __pyx_v_res;
      double __pyx_v_prev;
      int __pyx_v_ret;
      skiplist_t *__pyx_v_sl;
      Py_ssize_t __pyx_v_midpoint;
      Py_ssize_t __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_arg;
      __Pyx_Buffer __pyx_pybuffer_arg;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_median_c", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_arg.pybuffer.buf = NULL;
      __pyx_pybuffer_arg.refcount = 0;
      __pyx_pybuffernd_arg.data = NULL;
      __pyx_pybuffernd_arg.rcbuffer = &__pyx_pybuffer_arg;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arg.rcbuffer->pybuffer, (PyObject*)__pyx_v_arg, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_arg.diminfo[0].strides = __pyx_pybuffernd_arg.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arg.diminfo[0].shape = __pyx_pybuffernd_arg.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1304
     * from skiplist cimport *
     *
     * def roll_median_c(ndarray[float64_t] arg, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, res, prev
     *     cdef:
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arg.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_median_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arg.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1304
     * from skiplist cimport *
     *
     * def roll_median_c(ndarray[float64_t] arg, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, res, prev
     *     cdef:
     */
      __pyx_tuple__254 = PyTuple_Pack(13, __pyx_n_s_arg, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_val, __pyx_n_s_res, __pyx_n_s_prev, __pyx_n_s_ret, __pyx_n_s_sl, __pyx_n_s_midpoint, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output); if (unlikely(!__pyx_tuple__254)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__254);
      __Pyx_GIVEREF(__pyx_tuple__254);

      /* "pandas/algos.pyx":1304
     * from skiplist cimport *
     *
     * def roll_median_c(ndarray[float64_t] arg, int win, int minp):             # <<<<<<<<<<<<<<
     *     cdef double val, res, prev
     *     cdef:
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_39roll_median_c, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_median_c, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__255 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__254, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_median_c, 1304, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1305:     cdef double val, res, prev

     1306:     cdef:

     1307:         int ret=0

      /* "pandas/algos.pyx":1307
     *     cdef double val, res, prev
     *     cdef:
     *         int ret=0             # <<<<<<<<<<<<<<
     *         skiplist_t *sl
     *         Py_ssize_t midpoint, nobs = 0, i
     */
      __pyx_v_ret = 0;

     1308:         skiplist_t *sl

     1309:         Py_ssize_t midpoint, nobs = 0, i

      /* "pandas/algos.pyx":1309
     *         int ret=0
     *         skiplist_t *sl
     *         Py_ssize_t midpoint, nobs = 0, i             # <<<<<<<<<<<<<<
     *
     *
     */
      __pyx_v_nobs = 0;

     1310:

     1311:

     1312:     cdef Py_ssize_t N = len(arg)

      /* "pandas/algos.pyx":1312
     *
     *
     *     cdef Py_ssize_t N = len(arg)             # <<<<<<<<<<<<<<
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_arg)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     1313:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":1313
     *
     *     cdef Py_ssize_t N = len(arg)
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     sl = skiplist_init(win)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1314:

     1315:     sl = skiplist_init(win)

      /* "pandas/algos.pyx":1315
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     *     sl = skiplist_init(win)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(win, minp, N)
     */
      __pyx_v_sl = skiplist_init(__pyx_v_win);

     1316:

     1317:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":1317
     *     sl = skiplist_init(win)
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     1318:

     1319:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":1319
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = arg[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     1320:         val = arg[i]

        /* "pandas/algos.pyx":1320
     *
     *     for i from 0 <= i < minp - 1:
     *         val = arg[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_arg.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_arg.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_arg.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_arg.diminfo[0].strides));

     1321:

     1322:         # Not NaN

     1323:         if val == val:

        /* "pandas/algos.pyx":1323
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             skiplist_insert(sl, val)
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1324:             nobs += 1

          /* "pandas/algos.pyx":1324
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             skiplist_insert(sl, val)
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1325:             skiplist_insert(sl, val)

          /* "pandas/algos.pyx":1325
     *         if val == val:
     *             nobs += 1
     *             skiplist_insert(sl, val)             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          skiplist_insert(__pyx_v_sl, __pyx_v_val);
          goto __pyx_L5;
        }
        __pyx_L5:;

     1326:

     1327:         output[i] = NaN

        /* "pandas/algos.pyx":1327
     *             skiplist_insert(sl, val)
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1328:

     1329:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":1329
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = arg[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     1330:         val = arg[i]

        /* "pandas/algos.pyx":1330
     *
     *     for i from minp - 1 <= i < N:
     *         val = arg[i]             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_arg.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_arg.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_arg.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_arg.diminfo[0].strides));

     1331:

     1332:         if i > win - 1:

        /* "pandas/algos.pyx":1332
     *         val = arg[i]
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = arg[i - win]
     *
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     1333:             prev = arg[i - win]

          /* "pandas/algos.pyx":1333
     *
     *         if i > win - 1:
     *             prev = arg[i - win]             # <<<<<<<<<<<<<<
     *
     *             if prev == prev:
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_arg.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_arg.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_arg.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_arg.diminfo[0].strides));

     1334:

     1335:             if prev == prev:

          /* "pandas/algos.pyx":1335
     *             prev = arg[i - win]
     *
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 skiplist_remove(sl, prev)
     *                 nobs -= 1
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     1336:                 skiplist_remove(sl, prev)

            /* "pandas/algos.pyx":1336
     *
     *             if prev == prev:
     *                 skiplist_remove(sl, prev)             # <<<<<<<<<<<<<<
     *                 nobs -= 1
     *
     */
            skiplist_remove(__pyx_v_sl, __pyx_v_prev);

     1337:                 nobs -= 1

            /* "pandas/algos.pyx":1337
     *             if prev == prev:
     *                 skiplist_remove(sl, prev)
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);
            goto __pyx_L9;
          }
          __pyx_L9:;
          goto __pyx_L8;
        }
        __pyx_L8:;

     1338:

     1339:         if val == val:

        /* "pandas/algos.pyx":1339
     *                 nobs -= 1
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             skiplist_insert(sl, val)
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1340:             nobs += 1

          /* "pandas/algos.pyx":1340
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             skiplist_insert(sl, val)
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1341:             skiplist_insert(sl, val)

          /* "pandas/algos.pyx":1341
     *         if val == val:
     *             nobs += 1
     *             skiplist_insert(sl, val)             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
          skiplist_insert(__pyx_v_sl, __pyx_v_val);
          goto __pyx_L10;
        }
        __pyx_L10:;

     1342:

     1343:         if nobs >= minp:

        /* "pandas/algos.pyx":1343
     *             skiplist_insert(sl, val)
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             midpoint = nobs / 2
     *             if nobs % 2:
     */
        __pyx_t_10 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_10) {

     1344:             midpoint = nobs / 2

          /* "pandas/algos.pyx":1344
     *
     *         if nobs >= minp:
     *             midpoint = nobs / 2             # <<<<<<<<<<<<<<
     *             if nobs % 2:
     *                 res = skiplist_get(sl, midpoint, &ret)
     */
          __pyx_v_midpoint = __Pyx_div_Py_ssize_t(__pyx_v_nobs, 2);

     1345:             if nobs % 2:

          /* "pandas/algos.pyx":1345
     *         if nobs >= minp:
     *             midpoint = nobs / 2
     *             if nobs % 2:             # <<<<<<<<<<<<<<
     *                 res = skiplist_get(sl, midpoint, &ret)
     *             else:
     */
          __pyx_t_10 = (__Pyx_mod_Py_ssize_t(__pyx_v_nobs, 2) != 0);
          if (__pyx_t_10) {

     1346:                 res = skiplist_get(sl, midpoint, &ret)

            /* "pandas/algos.pyx":1346
     *             midpoint = nobs / 2
     *             if nobs % 2:
     *                 res = skiplist_get(sl, midpoint, &ret)             # <<<<<<<<<<<<<<
     *             else:
     *                 res = (skiplist_get(sl, midpoint, &ret) +
     */
            __pyx_v_res = skiplist_get(__pyx_v_sl, __pyx_v_midpoint, (&__pyx_v_ret));
            goto __pyx_L12;
          }
          /*else*/ {

     1347:             else:

     1348:                 res = (skiplist_get(sl, midpoint, &ret) +

     1349:                        skiplist_get(sl, (midpoint - 1), &ret)) / 2

            /* "pandas/algos.pyx":1349
     *             else:
     *                 res = (skiplist_get(sl, midpoint, &ret) +
     *                        skiplist_get(sl, (midpoint - 1), &ret)) / 2             # <<<<<<<<<<<<<<
     *         else:
     *             res = NaN
     */
            __pyx_v_res = ((skiplist_get(__pyx_v_sl, __pyx_v_midpoint, (&__pyx_v_ret)) + skiplist_get(__pyx_v_sl, (__pyx_v_midpoint - 1), (&__pyx_v_ret))) / 2.0);
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        /*else*/ {

     1350:         else:

     1351:             res = NaN

          /* "pandas/algos.pyx":1351
     *                        skiplist_get(sl, (midpoint - 1), &ret)) / 2
     *         else:
     *             res = NaN             # <<<<<<<<<<<<<<
     *
     *         output[i] = res
     */
          __pyx_v_res = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L11:;

     1352:

     1353:         output[i] = res

        /* "pandas/algos.pyx":1353
     *             res = NaN
     *
     *         output[i] = res             # <<<<<<<<<<<<<<
     *
     *     skiplist_destroy(sl)
     */
        __pyx_t_15 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_15 < 0) {
          __pyx_t_15 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_15 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_res;
      }

     1354:

     1355:     skiplist_destroy(sl)

      /* "pandas/algos.pyx":1355
     *         output[i] = res
     *
     *     skiplist_destroy(sl)             # <<<<<<<<<<<<<<
     *
     *     return output
     */
      skiplist_destroy(__pyx_v_sl);

     1356:

     1357:     return output

      /* "pandas/algos.pyx":1357
     *     skiplist_destroy(sl)
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * def roll_median_cython(ndarray input, int win, int minp):
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1358:

     1359: def roll_median_cython(ndarray input, int win, int minp):

    /* "pandas/algos.pyx":1359
     *     return output
     *
     * def roll_median_cython(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_41roll_median_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_40roll_median_cython[] = "\n    O(N log(window)) implementation using skip list\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_41roll_median_cython = {__Pyx_NAMESTR("roll_median_cython"), (PyCFunction)__pyx_pw_6pandas_5algos_41roll_median_cython, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_40roll_median_cython)};
    static PyObject *__pyx_pw_6pandas_5algos_41roll_median_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_median_cython (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_median_cython", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_median_cython", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_median_cython") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_median_cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_median_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_40roll_median_cython(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_40roll_median_cython(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_median_cython", 0);

      /* "pandas/algos.pyx":1359
     *     return output
     *
     * def roll_median_cython(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("pandas.algos.roll_median_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1359
     *     return output
     *
     * def roll_median_cython(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */
      __pyx_tuple__256 = PyTuple_Pack(3, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp); if (unlikely(!__pyx_tuple__256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__256);
      __Pyx_GIVEREF(__pyx_tuple__256);

      /* "pandas/algos.pyx":1359
     *     return output
     *
     * def roll_median_cython(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_41roll_median_cython, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_median_cython, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__257 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__256, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_median_cython, 1359, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__257)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1360:     '''

     1361:     O(N log(window)) implementation using skip list

     1362:     '''

     1363:     return _roll_skiplist_op(input, win, minp, _get_median)

      /* "pandas/algos.pyx":1363
     *     O(N log(window)) implementation using skip list
     *     '''
     *     return _roll_skiplist_op(input, win, minp, _get_median)             # <<<<<<<<<<<<<<
     *
     * # Unfortunately had to resort to some hackery here, would like for
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6pandas_5algos__roll_skiplist_op(__pyx_v_input, __pyx_v_win, __pyx_v_minp, __pyx_f_6pandas_5algos__get_median); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

     1364:

     1365: # Unfortunately had to resort to some hackery here, would like for

     1366: # Cython to be able to get this right.

     1367:

     1368: cdef double_t _get_median(object sl, int nobs, int minp):

    /* "pandas/algos.pyx":1368
     * # Cython to be able to get this right.
     *
     * cdef double_t _get_median(object sl, int nobs, int minp):             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t midpoint
     *     cdef IndexableSkiplist skiplist = <IndexableSkiplist> sl
     */

    static __pyx_t_5numpy_double_t __pyx_f_6pandas_5algos__get_median(PyObject *__pyx_v_sl, int __pyx_v_nobs, int __pyx_v_minp) {
      Py_ssize_t __pyx_v_midpoint;
      struct __pyx_obj_6pandas_5algos_IndexableSkiplist *__pyx_v_skiplist = 0;
      __pyx_t_5numpy_double_t __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_get_median", 0);

      /* "pandas/algos.pyx":1368
     * # Cython to be able to get this right.
     *
     * cdef double_t _get_median(object sl, int nobs, int minp):             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t midpoint
     *     cdef IndexableSkiplist skiplist = <IndexableSkiplist> sl
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_WriteUnraisable("pandas.algos._get_median", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF((PyObject *)__pyx_v_skiplist);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     1369:     cdef Py_ssize_t midpoint

     1370:     cdef IndexableSkiplist skiplist = <IndexableSkiplist> sl

      /* "pandas/algos.pyx":1370
     * cdef double_t _get_median(object sl, int nobs, int minp):
     *     cdef Py_ssize_t midpoint
     *     cdef IndexableSkiplist skiplist = <IndexableSkiplist> sl             # <<<<<<<<<<<<<<
     *     if nobs >= minp:
     *         midpoint = nobs / 2
     */
      __pyx_t_1 = __pyx_v_sl;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_v_skiplist = ((struct __pyx_obj_6pandas_5algos_IndexableSkiplist *)__pyx_t_1);
      __pyx_t_1 = 0;

     1371:     if nobs >= minp:

      /* "pandas/algos.pyx":1371
     *     cdef Py_ssize_t midpoint
     *     cdef IndexableSkiplist skiplist = <IndexableSkiplist> sl
     *     if nobs >= minp:             # <<<<<<<<<<<<<<
     *         midpoint = nobs / 2
     *         if nobs % 2:
     */
      __pyx_t_2 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
      if (__pyx_t_2) {

     1372:         midpoint = nobs / 2

        /* "pandas/algos.pyx":1372
     *     cdef IndexableSkiplist skiplist = <IndexableSkiplist> sl
     *     if nobs >= minp:
     *         midpoint = nobs / 2             # <<<<<<<<<<<<<<
     *         if nobs % 2:
     *             return skiplist.get(midpoint)
     */
        __pyx_v_midpoint = __Pyx_div_long(__pyx_v_nobs, 2);

     1373:         if nobs % 2:

        /* "pandas/algos.pyx":1373
     *     if nobs >= minp:
     *         midpoint = nobs / 2
     *         if nobs % 2:             # <<<<<<<<<<<<<<
     *             return skiplist.get(midpoint)
     *         else:
     */
        __pyx_t_2 = (__Pyx_mod_long(__pyx_v_nobs, 2) != 0);
        if (__pyx_t_2) {

     1374:             return skiplist.get(midpoint)

          /* "pandas/algos.pyx":1374
     *         midpoint = nobs / 2
     *         if nobs % 2:
     *             return skiplist.get(midpoint)             # <<<<<<<<<<<<<<
     *         else:
     *             return (skiplist.get(midpoint) +
     */
          __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->get(__pyx_v_skiplist, __pyx_v_midpoint, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_r = __pyx_t_3;
          goto __pyx_L0;
        }
        /*else*/ {

     1375:         else:

     1376:             return (skiplist.get(midpoint) +

          /* "pandas/algos.pyx":1376
     *             return skiplist.get(midpoint)
     *         else:
     *             return (skiplist.get(midpoint) +             # <<<<<<<<<<<<<<
     *                     skiplist.get(midpoint - 1)) / 2
     *     else:
     */
          __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->get(__pyx_v_skiplist, __pyx_v_midpoint, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);

          /* "pandas/algos.pyx":1376
     *             return skiplist.get(midpoint)
     *         else:
     *             return (skiplist.get(midpoint) +             # <<<<<<<<<<<<<<
     *                     skiplist.get(midpoint - 1)) / 2
     *     else:
     */
          __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

     1377:                     skiplist.get(midpoint - 1)) / 2

          /* "pandas/algos.pyx":1377
     *         else:
     *             return (skiplist.get(midpoint) +
     *                     skiplist.get(midpoint - 1)) / 2             # <<<<<<<<<<<<<<
     *     else:
     *         return NaN
     */
          __pyx_t_4 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->get(__pyx_v_skiplist, (__pyx_v_midpoint - 1), 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);

          /* "pandas/algos.pyx":1377
     *         else:
     *             return (skiplist.get(midpoint) +
     *                     skiplist.get(midpoint - 1)) / 2             # <<<<<<<<<<<<<<
     *     else:
     *         return NaN
     */
          __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_int_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_3 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_r = __pyx_t_3;
          goto __pyx_L0;
        }
      }
      /*else*/ {

     1378:     else:

     1379:         return NaN

        /* "pandas/algos.pyx":1379
     *                     skiplist.get(midpoint - 1)) / 2
     *     else:
     *         return NaN             # <<<<<<<<<<<<<<
     *
     * #----------------------------------------------------------------------
     */
        __pyx_r = __pyx_v_6pandas_5algos_NaN;
        goto __pyx_L0;
      }

     1380:

     1381: #----------------------------------------------------------------------

     1382:

     1383: # Moving maximum / minimum code taken from Bottleneck under the terms

     1384: # of its Simplified BSD license

     1385: # https://github.com/kwgoodman/bottleneck

     1386:

     1387: cdef struct pairs:

    /* "pandas/algos.pyx":1387
     * # https://github.com/kwgoodman/bottleneck
     *
     * cdef struct pairs:             # <<<<<<<<<<<<<<
     *     double value
     *     int death
     */
    struct __pyx_t_6pandas_5algos_pairs {
      double value;
      int death;
    };

     1388:     double value

     1389:     int death

     1390:

     1391: from libc cimport stdlib

     1392:

     1393: @cython.boundscheck(False)

     1394: @cython.wraparound(False)

     1395: def roll_max2(ndarray[float64_t] a, int window, int minp):

    /* "pandas/algos.pyx":1395
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_max2(ndarray[float64_t] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving max of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_43roll_max2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_42roll_max2[] = "Moving max of 1d array of dtype=float64 along axis=0 ignoring NaNs.";
    static PyMethodDef __pyx_mdef_6pandas_5algos_43roll_max2 = {__Pyx_NAMESTR("roll_max2"), (PyCFunction)__pyx_pw_6pandas_5algos_43roll_max2, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_42roll_max2)};
    static PyObject *__pyx_pw_6pandas_5algos_43roll_max2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_a = 0;
      int __pyx_v_window;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_max2 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_window,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_max2", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_max2", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_max2") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_a = ((PyArrayObject *)values[0]);
        __pyx_v_window = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_window == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_max2", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_max2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_42roll_max2(__pyx_self, __pyx_v_a, __pyx_v_window, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_42roll_max2(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_a, int __pyx_v_window, int __pyx_v_minp) {
      __pyx_t_5numpy_float64_t __pyx_v_ai;
      __pyx_t_5numpy_float64_t __pyx_v_aold;
      Py_ssize_t __pyx_v_count;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_ring;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_minpair;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_end;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_last;
      Py_ssize_t __pyx_v_i0;
      npy_intp *__pyx_v_dim;
      Py_ssize_t __pyx_v_n0;
      npy_intp *__pyx_v_dims;
      PyArrayObject *__pyx_v_y = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_a;
      __Pyx_Buffer __pyx_pybuffer_a;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_y;
      __Pyx_Buffer __pyx_pybuffer_y;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_max2", 0);
      __pyx_pybuffer_y.pybuffer.buf = NULL;
      __pyx_pybuffer_y.refcount = 0;
      __pyx_pybuffernd_y.data = NULL;
      __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y;
      __pyx_pybuffer_a.pybuffer.buf = NULL;
      __pyx_pybuffer_a.refcount = 0;
      __pyx_pybuffernd_a.data = NULL;
      __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1395
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_max2(ndarray[float64_t] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving max of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_8);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_max2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_y);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1395
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_max2(ndarray[float64_t] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving max of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */
      __pyx_tuple__258 = PyTuple_Pack(15, __pyx_n_s_a, __pyx_n_s_window, __pyx_n_s_minp, __pyx_n_s_ai, __pyx_n_s_aold, __pyx_n_s_count, __pyx_n_s_ring, __pyx_n_s_minpair, __pyx_n_s_end, __pyx_n_s_last, __pyx_n_s_i0, __pyx_n_s_dim, __pyx_n_s_n0, __pyx_n_s_dims, __pyx_n_s_y); if (unlikely(!__pyx_tuple__258)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__258);
      __Pyx_GIVEREF(__pyx_tuple__258);

      /* "pandas/algos.pyx":1395
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_max2(ndarray[float64_t] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving max of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_43roll_max2, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_max2, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__259 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__258, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_max2, 1395, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__259)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1396:     "Moving max of 1d array of dtype=float64 along axis=0 ignoring NaNs."

     1397:     cdef np.float64_t ai, aold

     1398:     cdef Py_ssize_t count

     1399:     cdef pairs* ring

     1400:     cdef pairs* minpair

     1401:     cdef pairs* end

     1402:     cdef pairs* last

     1403:     cdef Py_ssize_t i0

     1404:     cdef np.npy_intp *dim

     1405:     dim = PyArray_DIMS(a)

      /* "pandas/algos.pyx":1405
     *     cdef Py_ssize_t i0
     *     cdef np.npy_intp *dim
     *     dim = PyArray_DIMS(a)             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t n0 = dim[0]
     *     cdef np.npy_intp *dims = [n0]
     */
      __pyx_v_dim = PyArray_DIMS(((PyArrayObject *)__pyx_v_a));

     1406:     cdef Py_ssize_t n0 = dim[0]

      /* "pandas/algos.pyx":1406
     *     cdef np.npy_intp *dim
     *     dim = PyArray_DIMS(a)
     *     cdef Py_ssize_t n0 = dim[0]             # <<<<<<<<<<<<<<
     *     cdef np.npy_intp *dims = [n0]
     *     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,
     */
      __pyx_v_n0 = (__pyx_v_dim[0]);

     1407:     cdef np.npy_intp *dims = [n0]

      /* "pandas/algos.pyx":1407
     *     dim = PyArray_DIMS(a)
     *     cdef Py_ssize_t n0 = dim[0]
     *     cdef np.npy_intp *dims = [n0]             # <<<<<<<<<<<<<<
     *     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,
     * 		NPY_float64, 0)
     */
      __pyx_t_1[0] = __pyx_v_n0;
      __pyx_v_dims = __pyx_t_1;

     1408:     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,

      /* "pandas/algos.pyx":1408
     *     cdef Py_ssize_t n0 = dim[0]
     *     cdef np.npy_intp *dims = [n0]
     *     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,             # <<<<<<<<<<<<<<
     * 		NPY_float64, 0)
     *
     */
      __pyx_t_2 = PyArray_EMPTY(1, __pyx_v_dims, NPY_FLOAT64, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_3 = 0;
      __pyx_v_y = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1409: 		NPY_float64, 0)

     1410:

     1411:     if window < 1:

      /* "pandas/algos.pyx":1411
     * 		NPY_float64, 0)
     *
     *     if window < 1:             # <<<<<<<<<<<<<<
     *         raise ValueError('Invalid window size %d'
     *                          % (window))
     */
      __pyx_t_4 = ((__pyx_v_window < 1) != 0);
      if (__pyx_t_4) {

     1412:         raise ValueError('Invalid window size %d'

        /* "pandas/algos.pyx":1412
     *
     *     if window < 1:
     *         raise ValueError('Invalid window size %d'             # <<<<<<<<<<<<<<
     *                          % (window))
     *
     */
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

     1413:                          % (window))

        /* "pandas/algos.pyx":1413
     *     if window < 1:
     *         raise ValueError('Invalid window size %d'
     *                          % (window))             # <<<<<<<<<<<<<<
     *
     *     if minp > window:
     */
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_window); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_window_size_d, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     1414:

     1415:     if minp > window:

      /* "pandas/algos.pyx":1415
     *                          % (window))
     *
     *     if minp > window:             # <<<<<<<<<<<<<<
     *         raise ValueError('Invalid min_periods size %d greater than window %d'
     *                         % (minp, window))
     */
      __pyx_t_4 = ((__pyx_v_minp > __pyx_v_window) != 0);
      if (__pyx_t_4) {

     1416:         raise ValueError('Invalid min_periods size %d greater than window %d'

        /* "pandas/algos.pyx":1416
     *
     *     if minp > window:
     *         raise ValueError('Invalid min_periods size %d greater than window %d'             # <<<<<<<<<<<<<<
     *                         % (minp, window))
     *
     */
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

     1417:                         % (minp, window))

        /* "pandas/algos.pyx":1417
     *     if minp > window:
     *         raise ValueError('Invalid min_periods size %d greater than window %d'
     *                         % (minp, window))             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(window, minp, n0)
     */
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_window); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_5 = 0;
        __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_min_periods_size_d_great, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

     1418:

     1419:     minp = _check_minp(window, minp, n0)

      /* "pandas/algos.pyx":1419
     *                         % (minp, window))
     *
     *     minp = _check_minp(window, minp, n0)             # <<<<<<<<<<<<<<
     *
     *     window = min(window, n0)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_window); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_n0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_minp = __pyx_t_9;

     1420:

     1421:     window = min(window, n0)

      /* "pandas/algos.pyx":1421
     *     minp = _check_minp(window, minp, n0)
     *
     *     window = min(window, n0)             # <<<<<<<<<<<<<<
     *
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))
     */
      __pyx_t_10 = __pyx_v_n0;
      __pyx_t_9 = __pyx_v_window;
      if (((__pyx_t_10 < __pyx_t_9) != 0)) {
        __pyx_t_11 = __pyx_t_10;
      } else {
        __pyx_t_11 = __pyx_t_9;
      }
      __pyx_v_window = __pyx_t_11;

     1422:

     1423:     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))

      /* "pandas/algos.pyx":1423
     *     window = min(window, n0)
     *
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))             # <<<<<<<<<<<<<<
     *     end = ring + window
     *     last = ring
     */
      __pyx_v_ring = ((struct __pyx_t_6pandas_5algos_pairs *)malloc((__pyx_v_window * (sizeof(struct __pyx_t_6pandas_5algos_pairs)))));

     1424:     end = ring + window

      /* "pandas/algos.pyx":1424
     *
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))
     *     end = ring + window             # <<<<<<<<<<<<<<
     *     last = ring
     *
     */
      __pyx_v_end = (__pyx_v_ring + __pyx_v_window);

     1425:     last = ring

      /* "pandas/algos.pyx":1425
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))
     *     end = ring + window
     *     last = ring             # <<<<<<<<<<<<<<
     *
     *     minpair = ring
     */
      __pyx_v_last = __pyx_v_ring;

     1426:

     1427:     minpair = ring

      /* "pandas/algos.pyx":1427
     *     last = ring
     *
     *     minpair = ring             # <<<<<<<<<<<<<<
     *     ai = a[0]
     *     if ai == ai:
     */
      __pyx_v_minpair = __pyx_v_ring;

     1428:     ai = a[0]

      /* "pandas/algos.pyx":1428
     *
     *     minpair = ring
     *     ai = a[0]             # <<<<<<<<<<<<<<
     *     if ai == ai:
     *         minpair.value = ai
     */
      __pyx_t_12 = 0;
      __pyx_v_ai = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_a.diminfo[0].strides));

     1429:     if ai == ai:

      /* "pandas/algos.pyx":1429
     *     minpair = ring
     *     ai = a[0]
     *     if ai == ai:             # <<<<<<<<<<<<<<
     *         minpair.value = ai
     *     else:
     */
      __pyx_t_4 = ((__pyx_v_ai == __pyx_v_ai) != 0);
      if (__pyx_t_4) {

     1430:         minpair.value = ai

        /* "pandas/algos.pyx":1430
     *     ai = a[0]
     *     if ai == ai:
     *         minpair.value = ai             # <<<<<<<<<<<<<<
     *     else:
     *         minpair.value = MINfloat64
     */
        __pyx_v_minpair->value = __pyx_v_ai;
        goto __pyx_L5;
      }
      /*else*/ {

     1431:     else:

     1432:         minpair.value = MINfloat64

        /* "pandas/algos.pyx":1432
     *         minpair.value = ai
     *     else:
     *         minpair.value = MINfloat64             # <<<<<<<<<<<<<<
     *     minpair.death = window
     *
     */
        __pyx_v_minpair->value = __pyx_v_6pandas_5algos_MINfloat64;
      }
      __pyx_L5:;

     1433:     minpair.death = window

      /* "pandas/algos.pyx":1433
     *     else:
     *         minpair.value = MINfloat64
     *     minpair.death = window             # <<<<<<<<<<<<<<
     *
     *     count = 0
     */
      __pyx_v_minpair->death = __pyx_v_window;

     1434:

     1435:     count = 0

      /* "pandas/algos.pyx":1435
     *     minpair.death = window
     *
     *     count = 0             # <<<<<<<<<<<<<<
     *     for i0 in range(n0):
     *         ai = a[i0]
     */
      __pyx_v_count = 0;

     1436:     for i0 in range(n0):

      /* "pandas/algos.pyx":1436
     *
     *     count = 0
     *     for i0 in range(n0):             # <<<<<<<<<<<<<<
     *         ai = a[i0]
     *         if ai == ai:
     */
      __pyx_t_11 = __pyx_v_n0;
      for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10+=1) {
        __pyx_v_i0 = __pyx_t_10;

     1437:         ai = a[i0]

        /* "pandas/algos.pyx":1437
     *     count = 0
     *     for i0 in range(n0):
     *         ai = a[i0]             # <<<<<<<<<<<<<<
     *         if ai == ai:
     *             count += 1
     */
        __pyx_t_13 = __pyx_v_i0;
        __pyx_v_ai = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_a.diminfo[0].strides));

     1438:         if ai == ai:

        /* "pandas/algos.pyx":1438
     *     for i0 in range(n0):
     *         ai = a[i0]
     *         if ai == ai:             # <<<<<<<<<<<<<<
     *             count += 1
     *         else:
     */
        __pyx_t_4 = ((__pyx_v_ai == __pyx_v_ai) != 0);
        if (__pyx_t_4) {

     1439:             count += 1

          /* "pandas/algos.pyx":1439
     *         ai = a[i0]
     *         if ai == ai:
     *             count += 1             # <<<<<<<<<<<<<<
     *         else:
     *             ai = MINfloat64
     */
          __pyx_v_count = (__pyx_v_count + 1);
          goto __pyx_L8;
        }
        /*else*/ {

     1440:         else:

     1441:             ai = MINfloat64

          /* "pandas/algos.pyx":1441
     *             count += 1
     *         else:
     *             ai = MINfloat64             # <<<<<<<<<<<<<<
     *         if i0 >= window:
     *             aold = a[i0 - window]
     */
          __pyx_v_ai = __pyx_v_6pandas_5algos_MINfloat64;
        }
        __pyx_L8:;

     1442:         if i0 >= window:

        /* "pandas/algos.pyx":1442
     *         else:
     *             ai = MINfloat64
     *         if i0 >= window:             # <<<<<<<<<<<<<<
     *             aold = a[i0 - window]
     *             if aold == aold:
     */
        __pyx_t_4 = ((__pyx_v_i0 >= __pyx_v_window) != 0);
        if (__pyx_t_4) {

     1443:             aold = a[i0 - window]

          /* "pandas/algos.pyx":1443
     *             ai = MINfloat64
     *         if i0 >= window:
     *             aold = a[i0 - window]             # <<<<<<<<<<<<<<
     *             if aold == aold:
     *                 count -= 1
     */
          __pyx_t_14 = (__pyx_v_i0 - __pyx_v_window);
          __pyx_v_aold = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_a.diminfo[0].strides));

     1444:             if aold == aold:

          /* "pandas/algos.pyx":1444
     *         if i0 >= window:
     *             aold = a[i0 - window]
     *             if aold == aold:             # <<<<<<<<<<<<<<
     *                 count -= 1
     *         if minpair.death == i0:
     */
          __pyx_t_4 = ((__pyx_v_aold == __pyx_v_aold) != 0);
          if (__pyx_t_4) {

     1445:                 count -= 1

            /* "pandas/algos.pyx":1445
     *             aold = a[i0 - window]
     *             if aold == aold:
     *                 count -= 1             # <<<<<<<<<<<<<<
     *         if minpair.death == i0:
     *             minpair += 1
     */
            __pyx_v_count = (__pyx_v_count - 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     1446:         if minpair.death == i0:

        /* "pandas/algos.pyx":1446
     *             if aold == aold:
     *                 count -= 1
     *         if minpair.death == i0:             # <<<<<<<<<<<<<<
     *             minpair += 1
     *             if minpair >= end:
     */
        __pyx_t_4 = ((__pyx_v_minpair->death == __pyx_v_i0) != 0);
        if (__pyx_t_4) {

     1447:             minpair += 1

          /* "pandas/algos.pyx":1447
     *                 count -= 1
     *         if minpair.death == i0:
     *             minpair += 1             # <<<<<<<<<<<<<<
     *             if minpair >= end:
     *                 minpair = ring
     */
          __pyx_v_minpair = (__pyx_v_minpair + 1);

     1448:             if minpair >= end:

          /* "pandas/algos.pyx":1448
     *         if minpair.death == i0:
     *             minpair += 1
     *             if minpair >= end:             # <<<<<<<<<<<<<<
     *                 minpair = ring
     *         if ai >= minpair.value:
     */
          __pyx_t_4 = ((__pyx_v_minpair >= __pyx_v_end) != 0);
          if (__pyx_t_4) {

     1449:                 minpair = ring

            /* "pandas/algos.pyx":1449
     *             minpair += 1
     *             if minpair >= end:
     *                 minpair = ring             # <<<<<<<<<<<<<<
     *         if ai >= minpair.value:
     *             minpair.value = ai
     */
            __pyx_v_minpair = __pyx_v_ring;
            goto __pyx_L12;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        __pyx_L11:;

     1450:         if ai >= minpair.value:

        /* "pandas/algos.pyx":1450
     *             if minpair >= end:
     *                 minpair = ring
     *         if ai >= minpair.value:             # <<<<<<<<<<<<<<
     *             minpair.value = ai
     *             minpair.death = i0 + window
     */
        __pyx_t_4 = ((__pyx_v_ai >= __pyx_v_minpair->value) != 0);
        if (__pyx_t_4) {

     1451:             minpair.value = ai

          /* "pandas/algos.pyx":1451
     *                 minpair = ring
     *         if ai >= minpair.value:
     *             minpair.value = ai             # <<<<<<<<<<<<<<
     *             minpair.death = i0 + window
     *             last = minpair
     */
          __pyx_v_minpair->value = __pyx_v_ai;

     1452:             minpair.death = i0 + window

          /* "pandas/algos.pyx":1452
     *         if ai >= minpair.value:
     *             minpair.value = ai
     *             minpair.death = i0 + window             # <<<<<<<<<<<<<<
     *             last = minpair
     *         else:
     */
          __pyx_v_minpair->death = (__pyx_v_i0 + __pyx_v_window);

     1453:             last = minpair

          /* "pandas/algos.pyx":1453
     *             minpair.value = ai
     *             minpair.death = i0 + window
     *             last = minpair             # <<<<<<<<<<<<<<
     *         else:
     *             while last.value <= ai:
     */
          __pyx_v_last = __pyx_v_minpair;
          goto __pyx_L13;
        }
        /*else*/ {

     1454:         else:

     1455:             while last.value <= ai:

          /* "pandas/algos.pyx":1455
     *             last = minpair
     *         else:
     *             while last.value <= ai:             # <<<<<<<<<<<<<<
     *                 if last == ring:
     *                     last = end
     */
          while (1) {
            __pyx_t_4 = ((__pyx_v_last->value <= __pyx_v_ai) != 0);
            if (!__pyx_t_4) break;

     1456:                 if last == ring:

            /* "pandas/algos.pyx":1456
     *         else:
     *             while last.value <= ai:
     *                 if last == ring:             # <<<<<<<<<<<<<<
     *                     last = end
     *                 last -= 1
     */
            __pyx_t_4 = ((__pyx_v_last == __pyx_v_ring) != 0);
            if (__pyx_t_4) {

     1457:                     last = end

              /* "pandas/algos.pyx":1457
     *             while last.value <= ai:
     *                 if last == ring:
     *                     last = end             # <<<<<<<<<<<<<<
     *                 last -= 1
     *             last += 1
     */
              __pyx_v_last = __pyx_v_end;
              goto __pyx_L16;
            }
            __pyx_L16:;

     1458:                 last -= 1

            /* "pandas/algos.pyx":1458
     *                 if last == ring:
     *                     last = end
     *                 last -= 1             # <<<<<<<<<<<<<<
     *             last += 1
     *             if last == end:
     */
            __pyx_v_last = (__pyx_v_last - 1);
          }

     1459:             last += 1

          /* "pandas/algos.pyx":1459
     *                     last = end
     *                 last -= 1
     *             last += 1             # <<<<<<<<<<<<<<
     *             if last == end:
     *                 last = ring
     */
          __pyx_v_last = (__pyx_v_last + 1);

     1460:             if last == end:

          /* "pandas/algos.pyx":1460
     *                 last -= 1
     *             last += 1
     *             if last == end:             # <<<<<<<<<<<<<<
     *                 last = ring
     *             last.value = ai
     */
          __pyx_t_4 = ((__pyx_v_last == __pyx_v_end) != 0);
          if (__pyx_t_4) {

     1461:                 last = ring

            /* "pandas/algos.pyx":1461
     *             last += 1
     *             if last == end:
     *                 last = ring             # <<<<<<<<<<<<<<
     *             last.value = ai
     *             last.death = i0 + window
     */
            __pyx_v_last = __pyx_v_ring;
            goto __pyx_L17;
          }
          __pyx_L17:;

     1462:             last.value = ai

          /* "pandas/algos.pyx":1462
     *             if last == end:
     *                 last = ring
     *             last.value = ai             # <<<<<<<<<<<<<<
     *             last.death = i0 + window
     *         if count >= minp:
     */
          __pyx_v_last->value = __pyx_v_ai;

     1463:             last.death = i0 + window

          /* "pandas/algos.pyx":1463
     *                 last = ring
     *             last.value = ai
     *             last.death = i0 + window             # <<<<<<<<<<<<<<
     *         if count >= minp:
     *             y[i0] = minpair.value
     */
          __pyx_v_last->death = (__pyx_v_i0 + __pyx_v_window);
        }
        __pyx_L13:;

     1464:         if count >= minp:

        /* "pandas/algos.pyx":1464
     *             last.value = ai
     *             last.death = i0 + window
     *         if count >= minp:             # <<<<<<<<<<<<<<
     *             y[i0] = minpair.value
     *         else:
     */
        __pyx_t_4 = ((__pyx_v_count >= __pyx_v_minp) != 0);
        if (__pyx_t_4) {

     1465:             y[i0] = minpair.value

          /* "pandas/algos.pyx":1465
     *             last.death = i0 + window
     *         if count >= minp:
     *             y[i0] = minpair.value             # <<<<<<<<<<<<<<
     *         else:
     *             y[i0] = NaN
     */
          __pyx_t_15 = __pyx_v_minpair->value;
          __pyx_t_16 = __pyx_v_i0;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_y.diminfo[0].strides) = __pyx_t_15;
          goto __pyx_L18;
        }
        /*else*/ {

     1466:         else:

     1467:             y[i0] = NaN

          /* "pandas/algos.pyx":1467
     *             y[i0] = minpair.value
     *         else:
     *             y[i0] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i0 in range(minp - 1):
     */
          __pyx_t_17 = __pyx_v_i0;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_y.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L18:;
      }

     1468:

     1469:     for i0 in range(minp - 1):

      /* "pandas/algos.pyx":1469
     *             y[i0] = NaN
     *
     *     for i0 in range(minp - 1):             # <<<<<<<<<<<<<<
     *         y[i0] = NaN
     *
     */
      __pyx_t_18 = (__pyx_v_minp - 1);
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_18; __pyx_t_11+=1) {
        __pyx_v_i0 = __pyx_t_11;

     1470:         y[i0] = NaN

        /* "pandas/algos.pyx":1470
     *
     *     for i0 in range(minp - 1):
     *         y[i0] = NaN             # <<<<<<<<<<<<<<
     *
     *     stdlib.free(ring)
     */
        __pyx_t_10 = __pyx_v_i0;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_y.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1471:

     1472:     stdlib.free(ring)

      /* "pandas/algos.pyx":1472
     *         y[i0] = NaN
     *
     *     stdlib.free(ring)             # <<<<<<<<<<<<<<
     *     return y
     *
     */
      free(__pyx_v_ring);

     1473:     return y

      /* "pandas/algos.pyx":1473
     *
     *     stdlib.free(ring)
     *     return y             # <<<<<<<<<<<<<<
     *
     * def roll_max(ndarray input, int win, int minp):
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_y));
      __pyx_r = ((PyObject *)__pyx_v_y);
      goto __pyx_L0;

     1474:

     1475: def roll_max(ndarray input, int win, int minp):

    /* "pandas/algos.pyx":1475
     *     return y
     *
     * def roll_max(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_45roll_max(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_44roll_max[] = "\n    O(N log(window)) implementation using skip list\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_45roll_max = {__Pyx_NAMESTR("roll_max"), (PyCFunction)__pyx_pw_6pandas_5algos_45roll_max, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_44roll_max)};
    static PyObject *__pyx_pw_6pandas_5algos_45roll_max(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_max (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_max", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_max", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_max") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_max", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_max", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_44roll_max(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_44roll_max(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_max", 0);

      /* "pandas/algos.pyx":1475
     *     return y
     *
     * def roll_max(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("pandas.algos.roll_max", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1475
     *     return y
     *
     * def roll_max(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */
      __pyx_tuple__260 = PyTuple_Pack(3, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp); if (unlikely(!__pyx_tuple__260)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__260);
      __Pyx_GIVEREF(__pyx_tuple__260);

      /* "pandas/algos.pyx":1475
     *     return y
     *
     * def roll_max(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_45roll_max, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_max, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__261 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__260, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_max, 1475, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__261)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1476:     '''

     1477:     O(N log(window)) implementation using skip list

     1478:     '''

     1479:     return _roll_skiplist_op(input, win, minp, _get_max)

      /* "pandas/algos.pyx":1479
     *     O(N log(window)) implementation using skip list
     *     '''
     *     return _roll_skiplist_op(input, win, minp, _get_max)             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6pandas_5algos__roll_skiplist_op(__pyx_v_input, __pyx_v_win, __pyx_v_minp, __pyx_f_6pandas_5algos__get_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

     1480:

     1481:

     1482: cdef double_t _get_max(object skiplist, int nobs, int minp):

    /* "pandas/algos.pyx":1482
     *
     *
     * cdef double_t _get_max(object skiplist, int nobs, int minp):             # <<<<<<<<<<<<<<
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(nobs - 1)
     */

    static __pyx_t_5numpy_double_t __pyx_f_6pandas_5algos__get_max(PyObject *__pyx_v_skiplist, int __pyx_v_nobs, int __pyx_v_minp) {
      __pyx_t_5numpy_double_t __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_get_max", 0);

      /* "pandas/algos.pyx":1482
     *
     *
     * cdef double_t _get_max(object skiplist, int nobs, int minp):             # <<<<<<<<<<<<<<
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(nobs - 1)
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_WriteUnraisable("pandas.algos._get_max", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     1483:     if nobs >= minp:

      /* "pandas/algos.pyx":1483
     *
     * cdef double_t _get_max(object skiplist, int nobs, int minp):
     *     if nobs >= minp:             # <<<<<<<<<<<<<<
     *         return <IndexableSkiplist> skiplist.get(nobs - 1)
     *     else:
     */
      __pyx_t_1 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
      if (__pyx_t_1) {

     1484:         return <IndexableSkiplist> skiplist.get(nobs - 1)

        /* "pandas/algos.pyx":1484
     * cdef double_t _get_max(object skiplist, int nobs, int minp):
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(nobs - 1)             # <<<<<<<<<<<<<<
     *     else:
     *         return NaN
     */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_skiplist, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_nobs - 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_5;
        goto __pyx_L0;
      }
      /*else*/ {

     1485:     else:

     1486:         return NaN

        /* "pandas/algos.pyx":1486
     *         return <IndexableSkiplist> skiplist.get(nobs - 1)
     *     else:
     *         return NaN             # <<<<<<<<<<<<<<
     *
     * def roll_min(ndarray input, int win, int minp):
     */
        __pyx_r = __pyx_v_6pandas_5algos_NaN;
        goto __pyx_L0;
      }

     1487:

     1488: def roll_min(ndarray input, int win, int minp):

    /* "pandas/algos.pyx":1488
     *         return NaN
     *
     * def roll_min(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_47roll_min(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_46roll_min[] = "\n    O(N log(window)) implementation using skip list\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_47roll_min = {__Pyx_NAMESTR("roll_min"), (PyCFunction)__pyx_pw_6pandas_5algos_47roll_min, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_46roll_min)};
    static PyObject *__pyx_pw_6pandas_5algos_47roll_min(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_min (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_min", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_min", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_min") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_min", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_min", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_46roll_min(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_46roll_min(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_min", 0);

      /* "pandas/algos.pyx":1488
     *         return NaN
     *
     * def roll_min(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("pandas.algos.roll_min", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1488
     *         return NaN
     *
     * def roll_min(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */
      __pyx_tuple__262 = PyTuple_Pack(3, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp); if (unlikely(!__pyx_tuple__262)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__262);
      __Pyx_GIVEREF(__pyx_tuple__262);

      /* "pandas/algos.pyx":1488
     *         return NaN
     *
     * def roll_min(ndarray input, int win, int minp):             # <<<<<<<<<<<<<<
     *     '''
     *     O(N log(window)) implementation using skip list
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_47roll_min, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_min, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__263 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__262, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_min, 1488, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__263)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1489:     '''

     1490:     O(N log(window)) implementation using skip list

     1491:     '''

     1492:     return _roll_skiplist_op(input, win, minp, _get_min)

      /* "pandas/algos.pyx":1492
     *     O(N log(window)) implementation using skip list
     *     '''
     *     return _roll_skiplist_op(input, win, minp, _get_min)             # <<<<<<<<<<<<<<
     *
     * @cython.boundscheck(False)
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6pandas_5algos__roll_skiplist_op(__pyx_v_input, __pyx_v_win, __pyx_v_minp, __pyx_f_6pandas_5algos__get_min); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

     1493:

     1494: @cython.boundscheck(False)

     1495: @cython.wraparound(False)

     1496: def roll_min2(np.ndarray[np.float64_t, ndim=1] a, int window, int minp):

    /* "pandas/algos.pyx":1496
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_min2(np.ndarray[np.float64_t, ndim=1] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving min of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_49roll_min2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_48roll_min2[] = "Moving min of 1d array of dtype=float64 along axis=0 ignoring NaNs.";
    static PyMethodDef __pyx_mdef_6pandas_5algos_49roll_min2 = {__Pyx_NAMESTR("roll_min2"), (PyCFunction)__pyx_pw_6pandas_5algos_49roll_min2, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_48roll_min2)};
    static PyObject *__pyx_pw_6pandas_5algos_49roll_min2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_a = 0;
      int __pyx_v_window;
      int __pyx_v_minp;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_min2 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_window,&__pyx_n_s_minp,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_min2", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_min2", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_min2") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_a = ((PyArrayObject *)values[0]);
        __pyx_v_window = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_window == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_min2", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_min2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_48roll_min2(__pyx_self, __pyx_v_a, __pyx_v_window, __pyx_v_minp);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_48roll_min2(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_a, int __pyx_v_window, int __pyx_v_minp) {
      __pyx_t_5numpy_float64_t __pyx_v_ai;
      __pyx_t_5numpy_float64_t __pyx_v_aold;
      Py_ssize_t __pyx_v_count;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_ring;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_minpair;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_end;
      struct __pyx_t_6pandas_5algos_pairs *__pyx_v_last;
      Py_ssize_t __pyx_v_i0;
      npy_intp *__pyx_v_dim;
      Py_ssize_t __pyx_v_n0;
      npy_intp *__pyx_v_dims;
      PyArrayObject *__pyx_v_y = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_a;
      __Pyx_Buffer __pyx_pybuffer_a;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_y;
      __Pyx_Buffer __pyx_pybuffer_y;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_min2", 0);
      __pyx_pybuffer_y.pybuffer.buf = NULL;
      __pyx_pybuffer_y.refcount = 0;
      __pyx_pybuffernd_y.data = NULL;
      __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y;
      __pyx_pybuffer_a.pybuffer.buf = NULL;
      __pyx_pybuffer_a.refcount = 0;
      __pyx_pybuffernd_a.data = NULL;
      __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1496
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_min2(np.ndarray[np.float64_t, ndim=1] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving min of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_t_11);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_min2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_y);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1496
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_min2(np.ndarray[np.float64_t, ndim=1] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving min of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */
      __pyx_tuple__264 = PyTuple_Pack(15, __pyx_n_s_a, __pyx_n_s_window, __pyx_n_s_minp, __pyx_n_s_ai, __pyx_n_s_aold, __pyx_n_s_count, __pyx_n_s_ring, __pyx_n_s_minpair, __pyx_n_s_end, __pyx_n_s_last, __pyx_n_s_i0, __pyx_n_s_dim, __pyx_n_s_n0, __pyx_n_s_dims, __pyx_n_s_y); if (unlikely(!__pyx_tuple__264)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__264);
      __Pyx_GIVEREF(__pyx_tuple__264);

      /* "pandas/algos.pyx":1496
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def roll_min2(np.ndarray[np.float64_t, ndim=1] a, int window, int minp):             # <<<<<<<<<<<<<<
     *     "Moving min of 1d array of dtype=float64 along axis=0 ignoring NaNs."
     *     cdef np.float64_t ai, aold
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_49roll_min2, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_min2, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__265 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__264, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_min2, 1496, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__265)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1497:     "Moving min of 1d array of dtype=float64 along axis=0 ignoring NaNs."

     1498:     cdef np.float64_t ai, aold

     1499:     cdef Py_ssize_t count

     1500:     cdef pairs* ring

     1501:     cdef pairs* minpair

     1502:     cdef pairs* end

     1503:     cdef pairs* last

     1504:     cdef Py_ssize_t i0

     1505:     cdef np.npy_intp *dim

     1506:     dim = PyArray_DIMS(a)

      /* "pandas/algos.pyx":1506
     *     cdef Py_ssize_t i0
     *     cdef np.npy_intp *dim
     *     dim = PyArray_DIMS(a)             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t n0 = dim[0]
     *     cdef np.npy_intp *dims = [n0]
     */
      __pyx_v_dim = PyArray_DIMS(((PyArrayObject *)__pyx_v_a));

     1507:     cdef Py_ssize_t n0 = dim[0]

      /* "pandas/algos.pyx":1507
     *     cdef np.npy_intp *dim
     *     dim = PyArray_DIMS(a)
     *     cdef Py_ssize_t n0 = dim[0]             # <<<<<<<<<<<<<<
     *     cdef np.npy_intp *dims = [n0]
     *     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,
     */
      __pyx_v_n0 = (__pyx_v_dim[0]);

     1508:     cdef np.npy_intp *dims = [n0]

      /* "pandas/algos.pyx":1508
     *     dim = PyArray_DIMS(a)
     *     cdef Py_ssize_t n0 = dim[0]
     *     cdef np.npy_intp *dims = [n0]             # <<<<<<<<<<<<<<
     *     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,
     * 		NPY_float64, 0)
     */
      __pyx_t_1[0] = __pyx_v_n0;
      __pyx_v_dims = __pyx_t_1;

     1509:     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,

      /* "pandas/algos.pyx":1509
     *     cdef Py_ssize_t n0 = dim[0]
     *     cdef np.npy_intp *dims = [n0]
     *     cdef np.ndarray[np.float64_t, ndim=1] y = PyArray_EMPTY(1, dims,             # <<<<<<<<<<<<<<
     * 		NPY_float64, 0)
     *
     */
      __pyx_t_2 = PyArray_EMPTY(1, __pyx_v_dims, NPY_FLOAT64, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_3 = 0;
      __pyx_v_y = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1510: 		NPY_float64, 0)

     1511:

     1512:     if window < 1:

      /* "pandas/algos.pyx":1512
     * 		NPY_float64, 0)
     *
     *     if window < 1:             # <<<<<<<<<<<<<<
     *         raise ValueError('Invalid window size %d'
     *                          % (window))
     */
      __pyx_t_4 = ((__pyx_v_window < 1) != 0);
      if (__pyx_t_4) {

     1513:         raise ValueError('Invalid window size %d'

        /* "pandas/algos.pyx":1513
     *
     *     if window < 1:
     *         raise ValueError('Invalid window size %d'             # <<<<<<<<<<<<<<
     *                          % (window))
     *
     */
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

     1514:                          % (window))

        /* "pandas/algos.pyx":1514
     *     if window < 1:
     *         raise ValueError('Invalid window size %d'
     *                          % (window))             # <<<<<<<<<<<<<<
     *
     *     if minp > window:
     */
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_window); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_window_size_d, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     1515:

     1516:     if minp > window:

      /* "pandas/algos.pyx":1516
     *                          % (window))
     *
     *     if minp > window:             # <<<<<<<<<<<<<<
     *         raise ValueError('Invalid min_periods size %d greater than window %d'
     *                         % (minp, window))
     */
      __pyx_t_4 = ((__pyx_v_minp > __pyx_v_window) != 0);
      if (__pyx_t_4) {

     1517:         raise ValueError('Invalid min_periods size %d greater than window %d'

        /* "pandas/algos.pyx":1517
     *
     *     if minp > window:
     *         raise ValueError('Invalid min_periods size %d greater than window %d'             # <<<<<<<<<<<<<<
     *                         % (minp, window))
     *
     */
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

     1518:                         % (minp, window))

        /* "pandas/algos.pyx":1518
     *     if minp > window:
     *         raise ValueError('Invalid min_periods size %d greater than window %d'
     *                         % (minp, window))             # <<<<<<<<<<<<<<
     *
     *     window = min(window, n0)
     */
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_window); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_5 = 0;
        __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_min_periods_size_d_great, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

     1519:

     1520:     window = min(window, n0)

      /* "pandas/algos.pyx":1520
     *                         % (minp, window))
     *
     *     window = min(window, n0)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(window, minp, n0)
     */
      __pyx_t_7 = __pyx_v_n0;
      __pyx_t_8 = __pyx_v_window;
      if (((__pyx_t_7 < __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_7;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_v_window = __pyx_t_9;

     1521:

     1522:     minp = _check_minp(window, minp, n0)

      /* "pandas/algos.pyx":1522
     *     window = min(window, n0)
     *
     *     minp = _check_minp(window, minp, n0)             # <<<<<<<<<<<<<<
     *
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_window); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_n0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_10); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_minp = __pyx_t_8;

     1523:

     1524:     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))

      /* "pandas/algos.pyx":1524
     *     minp = _check_minp(window, minp, n0)
     *
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))             # <<<<<<<<<<<<<<
     *     end = ring + window
     *     last = ring
     */
      __pyx_v_ring = ((struct __pyx_t_6pandas_5algos_pairs *)malloc((__pyx_v_window * (sizeof(struct __pyx_t_6pandas_5algos_pairs)))));

     1525:     end = ring + window

      /* "pandas/algos.pyx":1525
     *
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))
     *     end = ring + window             # <<<<<<<<<<<<<<
     *     last = ring
     *
     */
      __pyx_v_end = (__pyx_v_ring + __pyx_v_window);

     1526:     last = ring

      /* "pandas/algos.pyx":1526
     *     ring = <pairs*>stdlib.malloc(window * sizeof(pairs))
     *     end = ring + window
     *     last = ring             # <<<<<<<<<<<<<<
     *
     *     minpair = ring
     */
      __pyx_v_last = __pyx_v_ring;

     1527:

     1528:     minpair = ring

      /* "pandas/algos.pyx":1528
     *     last = ring
     *
     *     minpair = ring             # <<<<<<<<<<<<<<
     *     ai = a[0]
     *     if ai == ai:
     */
      __pyx_v_minpair = __pyx_v_ring;

     1529:     ai = a[0]

      /* "pandas/algos.pyx":1529
     *
     *     minpair = ring
     *     ai = a[0]             # <<<<<<<<<<<<<<
     *     if ai == ai:
     *         minpair.value = ai
     */
      __pyx_t_12 = 0;
      __pyx_v_ai = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_a.diminfo[0].strides));

     1530:     if ai == ai:

      /* "pandas/algos.pyx":1530
     *     minpair = ring
     *     ai = a[0]
     *     if ai == ai:             # <<<<<<<<<<<<<<
     *         minpair.value = ai
     *     else:
     */
      __pyx_t_4 = ((__pyx_v_ai == __pyx_v_ai) != 0);
      if (__pyx_t_4) {

     1531:         minpair.value = ai

        /* "pandas/algos.pyx":1531
     *     ai = a[0]
     *     if ai == ai:
     *         minpair.value = ai             # <<<<<<<<<<<<<<
     *     else:
     *         minpair.value = MAXfloat64
     */
        __pyx_v_minpair->value = __pyx_v_ai;
        goto __pyx_L5;
      }
      /*else*/ {

     1532:     else:

     1533:         minpair.value = MAXfloat64

        /* "pandas/algos.pyx":1533
     *         minpair.value = ai
     *     else:
     *         minpair.value = MAXfloat64             # <<<<<<<<<<<<<<
     *     minpair.death = window
     *
     */
        __pyx_v_minpair->value = __pyx_v_6pandas_5algos_MAXfloat64;
      }
      __pyx_L5:;

     1534:     minpair.death = window

      /* "pandas/algos.pyx":1534
     *     else:
     *         minpair.value = MAXfloat64
     *     minpair.death = window             # <<<<<<<<<<<<<<
     *
     *     count = 0
     */
      __pyx_v_minpair->death = __pyx_v_window;

     1535:

     1536:     count = 0

      /* "pandas/algos.pyx":1536
     *     minpair.death = window
     *
     *     count = 0             # <<<<<<<<<<<<<<
     *     for i0 in range(n0):
     *         ai = a[i0]
     */
      __pyx_v_count = 0;

     1537:     for i0 in range(n0):

      /* "pandas/algos.pyx":1537
     *
     *     count = 0
     *     for i0 in range(n0):             # <<<<<<<<<<<<<<
     *         ai = a[i0]
     *         if ai == ai:
     */
      __pyx_t_9 = __pyx_v_n0;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_9; __pyx_t_7+=1) {
        __pyx_v_i0 = __pyx_t_7;

     1538:         ai = a[i0]

        /* "pandas/algos.pyx":1538
     *     count = 0
     *     for i0 in range(n0):
     *         ai = a[i0]             # <<<<<<<<<<<<<<
     *         if ai == ai:
     *             count += 1
     */
        __pyx_t_13 = __pyx_v_i0;
        __pyx_v_ai = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_a.diminfo[0].strides));

     1539:         if ai == ai:

        /* "pandas/algos.pyx":1539
     *     for i0 in range(n0):
     *         ai = a[i0]
     *         if ai == ai:             # <<<<<<<<<<<<<<
     *             count += 1
     *         else:
     */
        __pyx_t_4 = ((__pyx_v_ai == __pyx_v_ai) != 0);
        if (__pyx_t_4) {

     1540:             count += 1

          /* "pandas/algos.pyx":1540
     *         ai = a[i0]
     *         if ai == ai:
     *             count += 1             # <<<<<<<<<<<<<<
     *         else:
     *             ai = MAXfloat64
     */
          __pyx_v_count = (__pyx_v_count + 1);
          goto __pyx_L8;
        }
        /*else*/ {

     1541:         else:

     1542:             ai = MAXfloat64

          /* "pandas/algos.pyx":1542
     *             count += 1
     *         else:
     *             ai = MAXfloat64             # <<<<<<<<<<<<<<
     *         if i0 >= window:
     *             aold = a[i0 - window]
     */
          __pyx_v_ai = __pyx_v_6pandas_5algos_MAXfloat64;
        }
        __pyx_L8:;

     1543:         if i0 >= window:

        /* "pandas/algos.pyx":1543
     *         else:
     *             ai = MAXfloat64
     *         if i0 >= window:             # <<<<<<<<<<<<<<
     *             aold = a[i0 - window]
     *             if aold == aold:
     */
        __pyx_t_4 = ((__pyx_v_i0 >= __pyx_v_window) != 0);
        if (__pyx_t_4) {

     1544:             aold = a[i0 - window]

          /* "pandas/algos.pyx":1544
     *             ai = MAXfloat64
     *         if i0 >= window:
     *             aold = a[i0 - window]             # <<<<<<<<<<<<<<
     *             if aold == aold:
     *                 count -= 1
     */
          __pyx_t_14 = (__pyx_v_i0 - __pyx_v_window);
          __pyx_v_aold = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_a.diminfo[0].strides));

     1545:             if aold == aold:

          /* "pandas/algos.pyx":1545
     *         if i0 >= window:
     *             aold = a[i0 - window]
     *             if aold == aold:             # <<<<<<<<<<<<<<
     *                 count -= 1
     *         if minpair.death == i0:
     */
          __pyx_t_4 = ((__pyx_v_aold == __pyx_v_aold) != 0);
          if (__pyx_t_4) {

     1546:                 count -= 1

            /* "pandas/algos.pyx":1546
     *             aold = a[i0 - window]
     *             if aold == aold:
     *                 count -= 1             # <<<<<<<<<<<<<<
     *         if minpair.death == i0:
     *             minpair += 1
     */
            __pyx_v_count = (__pyx_v_count - 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;

     1547:         if minpair.death == i0:

        /* "pandas/algos.pyx":1547
     *             if aold == aold:
     *                 count -= 1
     *         if minpair.death == i0:             # <<<<<<<<<<<<<<
     *             minpair += 1
     *             if minpair >= end:
     */
        __pyx_t_4 = ((__pyx_v_minpair->death == __pyx_v_i0) != 0);
        if (__pyx_t_4) {

     1548:             minpair += 1

          /* "pandas/algos.pyx":1548
     *                 count -= 1
     *         if minpair.death == i0:
     *             minpair += 1             # <<<<<<<<<<<<<<
     *             if minpair >= end:
     *                 minpair = ring
     */
          __pyx_v_minpair = (__pyx_v_minpair + 1);

     1549:             if minpair >= end:

          /* "pandas/algos.pyx":1549
     *         if minpair.death == i0:
     *             minpair += 1
     *             if minpair >= end:             # <<<<<<<<<<<<<<
     *                 minpair = ring
     *         if ai <= minpair.value:
     */
          __pyx_t_4 = ((__pyx_v_minpair >= __pyx_v_end) != 0);
          if (__pyx_t_4) {

     1550:                 minpair = ring

            /* "pandas/algos.pyx":1550
     *             minpair += 1
     *             if minpair >= end:
     *                 minpair = ring             # <<<<<<<<<<<<<<
     *         if ai <= minpair.value:
     *             minpair.value = ai
     */
            __pyx_v_minpair = __pyx_v_ring;
            goto __pyx_L12;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        __pyx_L11:;

     1551:         if ai <= minpair.value:

        /* "pandas/algos.pyx":1551
     *             if minpair >= end:
     *                 minpair = ring
     *         if ai <= minpair.value:             # <<<<<<<<<<<<<<
     *             minpair.value = ai
     *             minpair.death = i0 + window
     */
        __pyx_t_4 = ((__pyx_v_ai <= __pyx_v_minpair->value) != 0);
        if (__pyx_t_4) {

     1552:             minpair.value = ai

          /* "pandas/algos.pyx":1552
     *                 minpair = ring
     *         if ai <= minpair.value:
     *             minpair.value = ai             # <<<<<<<<<<<<<<
     *             minpair.death = i0 + window
     *             last = minpair
     */
          __pyx_v_minpair->value = __pyx_v_ai;

     1553:             minpair.death = i0 + window

          /* "pandas/algos.pyx":1553
     *         if ai <= minpair.value:
     *             minpair.value = ai
     *             minpair.death = i0 + window             # <<<<<<<<<<<<<<
     *             last = minpair
     *         else:
     */
          __pyx_v_minpair->death = (__pyx_v_i0 + __pyx_v_window);

     1554:             last = minpair

          /* "pandas/algos.pyx":1554
     *             minpair.value = ai
     *             minpair.death = i0 + window
     *             last = minpair             # <<<<<<<<<<<<<<
     *         else:
     *             while last.value >= ai:
     */
          __pyx_v_last = __pyx_v_minpair;
          goto __pyx_L13;
        }
        /*else*/ {

     1555:         else:

     1556:             while last.value >= ai:

          /* "pandas/algos.pyx":1556
     *             last = minpair
     *         else:
     *             while last.value >= ai:             # <<<<<<<<<<<<<<
     *                 if last == ring:
     *                     last = end
     */
          while (1) {
            __pyx_t_4 = ((__pyx_v_last->value >= __pyx_v_ai) != 0);
            if (!__pyx_t_4) break;

     1557:                 if last == ring:

            /* "pandas/algos.pyx":1557
     *         else:
     *             while last.value >= ai:
     *                 if last == ring:             # <<<<<<<<<<<<<<
     *                     last = end
     *                 last -= 1
     */
            __pyx_t_4 = ((__pyx_v_last == __pyx_v_ring) != 0);
            if (__pyx_t_4) {

     1558:                     last = end

              /* "pandas/algos.pyx":1558
     *             while last.value >= ai:
     *                 if last == ring:
     *                     last = end             # <<<<<<<<<<<<<<
     *                 last -= 1
     *             last += 1
     */
              __pyx_v_last = __pyx_v_end;
              goto __pyx_L16;
            }
            __pyx_L16:;

     1559:                 last -= 1

            /* "pandas/algos.pyx":1559
     *                 if last == ring:
     *                     last = end
     *                 last -= 1             # <<<<<<<<<<<<<<
     *             last += 1
     *             if last == end:
     */
            __pyx_v_last = (__pyx_v_last - 1);
          }

     1560:             last += 1

          /* "pandas/algos.pyx":1560
     *                     last = end
     *                 last -= 1
     *             last += 1             # <<<<<<<<<<<<<<
     *             if last == end:
     *                 last = ring
     */
          __pyx_v_last = (__pyx_v_last + 1);

     1561:             if last == end:

          /* "pandas/algos.pyx":1561
     *                 last -= 1
     *             last += 1
     *             if last == end:             # <<<<<<<<<<<<<<
     *                 last = ring
     *             last.value = ai
     */
          __pyx_t_4 = ((__pyx_v_last == __pyx_v_end) != 0);
          if (__pyx_t_4) {

     1562:                 last = ring

            /* "pandas/algos.pyx":1562
     *             last += 1
     *             if last == end:
     *                 last = ring             # <<<<<<<<<<<<<<
     *             last.value = ai
     *             last.death = i0 + window
     */
            __pyx_v_last = __pyx_v_ring;
            goto __pyx_L17;
          }
          __pyx_L17:;

     1563:             last.value = ai

          /* "pandas/algos.pyx":1563
     *             if last == end:
     *                 last = ring
     *             last.value = ai             # <<<<<<<<<<<<<<
     *             last.death = i0 + window
     *         if count >= minp:
     */
          __pyx_v_last->value = __pyx_v_ai;

     1564:             last.death = i0 + window

          /* "pandas/algos.pyx":1564
     *                 last = ring
     *             last.value = ai
     *             last.death = i0 + window             # <<<<<<<<<<<<<<
     *         if count >= minp:
     *             y[i0] = minpair.value
     */
          __pyx_v_last->death = (__pyx_v_i0 + __pyx_v_window);
        }
        __pyx_L13:;

     1565:         if count >= minp:

        /* "pandas/algos.pyx":1565
     *             last.value = ai
     *             last.death = i0 + window
     *         if count >= minp:             # <<<<<<<<<<<<<<
     *             y[i0] = minpair.value
     *         else:
     */
        __pyx_t_4 = ((__pyx_v_count >= __pyx_v_minp) != 0);
        if (__pyx_t_4) {

     1566:             y[i0] = minpair.value

          /* "pandas/algos.pyx":1566
     *             last.death = i0 + window
     *         if count >= minp:
     *             y[i0] = minpair.value             # <<<<<<<<<<<<<<
     *         else:
     *             y[i0] = NaN
     */
          __pyx_t_15 = __pyx_v_minpair->value;
          __pyx_t_16 = __pyx_v_i0;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_y.diminfo[0].strides) = __pyx_t_15;
          goto __pyx_L18;
        }
        /*else*/ {

     1567:         else:

     1568:             y[i0] = NaN

          /* "pandas/algos.pyx":1568
     *             y[i0] = minpair.value
     *         else:
     *             y[i0] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i0 in range(minp - 1):
     */
          __pyx_t_17 = __pyx_v_i0;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_y.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L18:;
      }

     1569:

     1570:     for i0 in range(minp - 1):

      /* "pandas/algos.pyx":1570
     *             y[i0] = NaN
     *
     *     for i0 in range(minp - 1):             # <<<<<<<<<<<<<<
     *         y[i0] = NaN
     *
     */
      __pyx_t_18 = (__pyx_v_minp - 1);
      for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_18; __pyx_t_9+=1) {
        __pyx_v_i0 = __pyx_t_9;

     1571:         y[i0] = NaN

        /* "pandas/algos.pyx":1571
     *
     *     for i0 in range(minp - 1):
     *         y[i0] = NaN             # <<<<<<<<<<<<<<
     *
     *     stdlib.free(ring)
     */
        __pyx_t_7 = __pyx_v_i0;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_y.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1572:

     1573:     stdlib.free(ring)

      /* "pandas/algos.pyx":1573
     *         y[i0] = NaN
     *
     *     stdlib.free(ring)             # <<<<<<<<<<<<<<
     *     return y
     *
     */
      free(__pyx_v_ring);

     1574:     return y

      /* "pandas/algos.pyx":1574
     *
     *     stdlib.free(ring)
     *     return y             # <<<<<<<<<<<<<<
     *
     * cdef double_t _get_min(object skiplist, int nobs, int minp):
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_y));
      __pyx_r = ((PyObject *)__pyx_v_y);
      goto __pyx_L0;

     1575:

     1576: cdef double_t _get_min(object skiplist, int nobs, int minp):

    /* "pandas/algos.pyx":1576
     *     return y
     *
     * cdef double_t _get_min(object skiplist, int nobs, int minp):             # <<<<<<<<<<<<<<
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(0)
     */

    static __pyx_t_5numpy_double_t __pyx_f_6pandas_5algos__get_min(PyObject *__pyx_v_skiplist, int __pyx_v_nobs, int __pyx_v_minp) {
      __pyx_t_5numpy_double_t __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_get_min", 0);

      /* "pandas/algos.pyx":1576
     *     return y
     *
     * cdef double_t _get_min(object skiplist, int nobs, int minp):             # <<<<<<<<<<<<<<
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(0)
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_WriteUnraisable("pandas.algos._get_min", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     1577:     if nobs >= minp:

      /* "pandas/algos.pyx":1577
     *
     * cdef double_t _get_min(object skiplist, int nobs, int minp):
     *     if nobs >= minp:             # <<<<<<<<<<<<<<
     *         return <IndexableSkiplist> skiplist.get(0)
     *     else:
     */
      __pyx_t_1 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
      if (__pyx_t_1) {

     1578:         return <IndexableSkiplist> skiplist.get(0)

        /* "pandas/algos.pyx":1578
     * cdef double_t _get_min(object skiplist, int nobs, int minp):
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(0)             # <<<<<<<<<<<<<<
     *     else:
     *         return NaN
     */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_skiplist, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_4;
        goto __pyx_L0;
      }
      /*else*/ {

      /* "pandas/algos.pyx":1578
     * cdef double_t _get_min(object skiplist, int nobs, int minp):
     *     if nobs >= minp:
     *         return <IndexableSkiplist> skiplist.get(0)             # <<<<<<<<<<<<<<
     *     else:
     *         return NaN
     */
      __pyx_tuple__29 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__29);
      __Pyx_GIVEREF(__pyx_tuple__29);

     1579:     else:

     1580:         return NaN

        /* "pandas/algos.pyx":1580
     *         return <IndexableSkiplist> skiplist.get(0)
     *     else:
     *         return NaN             # <<<<<<<<<<<<<<
     *
     * def roll_quantile(ndarray[float64_t, cast=True] input, int win,
     */
        __pyx_r = __pyx_v_6pandas_5algos_NaN;
        goto __pyx_L0;
      }

     1581:

     1582: def roll_quantile(ndarray[float64_t, cast=True] input, int win,

    /* "pandas/algos.pyx":1582
     *         return NaN
     *
     * def roll_quantile(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                   int minp, double quantile):
     *     '''
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_51roll_quantile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_50roll_quantile[] = "\n    O(N log(window)) implementation using skip list\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_51roll_quantile = {__Pyx_NAMESTR("roll_quantile"), (PyCFunction)__pyx_pw_6pandas_5algos_51roll_quantile, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_50roll_quantile)};
    static PyObject *__pyx_pw_6pandas_5algos_51roll_quantile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      double __pyx_v_quantile;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_quantile (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,&__pyx_n_s_quantile,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_quantile", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_quantile", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantile)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_quantile", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_quantile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1583; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_quantile = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantile == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1583; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_quantile", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_quantile", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_50roll_quantile(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp, __pyx_v_quantile);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_50roll_quantile(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp, double __pyx_v_quantile) {
      double __pyx_v_val;
      double __pyx_v_prev;
      struct __pyx_obj_6pandas_5algos_IndexableSkiplist *__pyx_v_skiplist = 0;
      Py_ssize_t __pyx_v_nobs;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_N;
      PyArrayObject *__pyx_v_output = 0;
      PyObject *__pyx_v_idx = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_quantile", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 1, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1582
     *         return NaN
     *
     * def roll_quantile(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                   int minp, double quantile):
     *     '''
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_quantile", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_skiplist);
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XDECREF(__pyx_v_idx);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1582
     *         return NaN
     *
     * def roll_quantile(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                   int minp, double quantile):
     *     '''
     */
      __pyx_tuple__266 = PyTuple_Pack(13, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_quantile, __pyx_n_s_val, __pyx_n_s_prev, __pyx_n_s_midpoint, __pyx_n_s_skiplist, __pyx_n_s_nobs, __pyx_n_s_i, __pyx_n_s_N, __pyx_n_s_output, __pyx_n_s_idx); if (unlikely(!__pyx_tuple__266)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__266);
      __Pyx_GIVEREF(__pyx_tuple__266);

      /* "pandas/algos.pyx":1582
     *         return NaN
     *
     * def roll_quantile(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                   int minp, double quantile):
     *     '''
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_51roll_quantile, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_quantile, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__267 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__266, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_quantile, 1582, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__267)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1583:                   int minp, double quantile):

     1584:     '''

     1585:     O(N log(window)) implementation using skip list

     1586:     '''

     1587:     cdef double val, prev, midpoint

     1588:     cdef IndexableSkiplist skiplist

     1589:     cdef Py_ssize_t nobs = 0, i

      /* "pandas/algos.pyx":1589
     *     cdef double val, prev, midpoint
     *     cdef IndexableSkiplist skiplist
     *     cdef Py_ssize_t nobs = 0, i             # <<<<<<<<<<<<<<
     *     cdef Py_ssize_t N = len(input)
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     */
      __pyx_v_nobs = 0;

     1590:     cdef Py_ssize_t N = len(input)

      /* "pandas/algos.pyx":1590
     *     cdef IndexableSkiplist skiplist
     *     cdef Py_ssize_t nobs = 0, i
     *     cdef Py_ssize_t N = len(input)             # <<<<<<<<<<<<<<
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_N = __pyx_t_1;

     1591:     cdef ndarray[double_t] output = np.empty(N, dtype=float)

      /* "pandas/algos.pyx":1591
     *     cdef Py_ssize_t nobs = 0, i
     *     cdef Py_ssize_t N = len(input)
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     skiplist = IndexableSkiplist(win)
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_output = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_output.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1592:

     1593:     skiplist = IndexableSkiplist(win)

      /* "pandas/algos.pyx":1593
     *     cdef ndarray[double_t] output = np.empty(N, dtype=float)
     *
     *     skiplist = IndexableSkiplist(win)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(win, minp, N)
     */
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6pandas_5algos_IndexableSkiplist)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_skiplist = ((struct __pyx_obj_6pandas_5algos_IndexableSkiplist *)__pyx_t_5);
      __pyx_t_5 = 0;

     1594:

     1595:     minp = _check_minp(win, minp, N)

      /* "pandas/algos.pyx":1595
     *     skiplist = IndexableSkiplist(win)
     *
     *     minp = _check_minp(win, minp, N)             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < minp - 1:
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_minp = __pyx_t_8;

     1596:

     1597:     for i from 0 <= i < minp - 1:

      /* "pandas/algos.pyx":1597
     *     minp = _check_minp(win, minp, N)
     *
     *     for i from 0 <= i < minp - 1:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_9 = (__pyx_v_minp - 1);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

     1598:         val = input[i]

        /* "pandas/algos.pyx":1598
     *
     *     for i from 0 <= i < minp - 1:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         # Not NaN
     */
        __pyx_t_1 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_1 < 0) {
          __pyx_t_1 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_1 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_input.diminfo[0].strides));

     1599:

     1600:         # Not NaN

     1601:         if val == val:

        /* "pandas/algos.pyx":1601
     *
     *         # Not NaN
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             skiplist.insert(val)
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1602:             nobs += 1

          /* "pandas/algos.pyx":1602
     *         # Not NaN
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             skiplist.insert(val)
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1603:             skiplist.insert(val)

          /* "pandas/algos.pyx":1603
     *         if val == val:
     *             nobs += 1
     *             skiplist.insert(val)             # <<<<<<<<<<<<<<
     *
     *         output[i] = NaN
     */
          __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->insert(__pyx_v_skiplist, __pyx_v_val, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L5;
        }
        __pyx_L5:;

     1604:

     1605:         output[i] = NaN

        /* "pandas/algos.pyx":1605
     *             skiplist.insert(val)
     *
     *         output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from minp - 1 <= i < N:
     */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_output.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
      }

     1606:

     1607:     for i from minp - 1 <= i < N:

      /* "pandas/algos.pyx":1607
     *         output[i] = NaN
     *
     *     for i from minp - 1 <= i < N:             # <<<<<<<<<<<<<<
     *         val = input[i]
     *
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = (__pyx_v_minp - 1); __pyx_v_i < __pyx_t_12; __pyx_v_i++) {

     1608:         val = input[i]

        /* "pandas/algos.pyx":1608
     *
     *     for i from minp - 1 <= i < N:
     *         val = input[i]             # <<<<<<<<<<<<<<
     *
     *         if i > win - 1:
     */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_input.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_input.diminfo[0].strides));

     1609:

     1610:         if i > win - 1:

        /* "pandas/algos.pyx":1610
     *         val = input[i]
     *
     *         if i > win - 1:             # <<<<<<<<<<<<<<
     *             prev = input[i - win]
     *
     */
        __pyx_t_10 = ((__pyx_v_i > (__pyx_v_win - 1)) != 0);
        if (__pyx_t_10) {

     1611:             prev = input[i - win]

          /* "pandas/algos.pyx":1611
     *
     *         if i > win - 1:
     *             prev = input[i - win]             # <<<<<<<<<<<<<<
     *
     *             if prev == prev:
     */
          __pyx_t_14 = (__pyx_v_i - __pyx_v_win);
          __pyx_t_8 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_input.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_prev = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_input.diminfo[0].strides));

     1612:

     1613:             if prev == prev:

          /* "pandas/algos.pyx":1613
     *             prev = input[i - win]
     *
     *             if prev == prev:             # <<<<<<<<<<<<<<
     *                 skiplist.remove(prev)
     *                 nobs -= 1
     */
          __pyx_t_10 = ((__pyx_v_prev == __pyx_v_prev) != 0);
          if (__pyx_t_10) {

     1614:                 skiplist.remove(prev)

            /* "pandas/algos.pyx":1614
     *
     *             if prev == prev:
     *                 skiplist.remove(prev)             # <<<<<<<<<<<<<<
     *                 nobs -= 1
     *
     */
            __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->remove(__pyx_v_skiplist, __pyx_v_prev, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     1615:                 nobs -= 1

            /* "pandas/algos.pyx":1615
     *             if prev == prev:
     *                 skiplist.remove(prev)
     *                 nobs -= 1             # <<<<<<<<<<<<<<
     *
     *         if val == val:
     */
            __pyx_v_nobs = (__pyx_v_nobs - 1);
            goto __pyx_L9;
          }
          __pyx_L9:;
          goto __pyx_L8;
        }
        __pyx_L8:;

     1616:

     1617:         if val == val:

        /* "pandas/algos.pyx":1617
     *                 nobs -= 1
     *
     *         if val == val:             # <<<<<<<<<<<<<<
     *             nobs += 1
     *             skiplist.insert(val)
     */
        __pyx_t_10 = ((__pyx_v_val == __pyx_v_val) != 0);
        if (__pyx_t_10) {

     1618:             nobs += 1

          /* "pandas/algos.pyx":1618
     *
     *         if val == val:
     *             nobs += 1             # <<<<<<<<<<<<<<
     *             skiplist.insert(val)
     *
     */
          __pyx_v_nobs = (__pyx_v_nobs + 1);

     1619:             skiplist.insert(val)

          /* "pandas/algos.pyx":1619
     *         if val == val:
     *             nobs += 1
     *             skiplist.insert(val)             # <<<<<<<<<<<<<<
     *
     *         if nobs >= minp:
     */
          __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->insert(__pyx_v_skiplist, __pyx_v_val, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;

     1620:

     1621:         if nobs >= minp:

        /* "pandas/algos.pyx":1621
     *             skiplist.insert(val)
     *
     *         if nobs >= minp:             # <<<<<<<<<<<<<<
     *             idx = int((quantile / 1.) * (nobs - 1))
     *             output[i] = skiplist.get(idx)
     */
        __pyx_t_10 = ((__pyx_v_nobs >= __pyx_v_minp) != 0);
        if (__pyx_t_10) {

     1622:             idx = int((quantile / 1.) * (nobs - 1))

          /* "pandas/algos.pyx":1622
     *
     *         if nobs >= minp:
     *             idx = int((quantile / 1.) * (nobs - 1))             # <<<<<<<<<<<<<<
     *             output[i] = skiplist.get(idx)
     *         else:
     */
          __pyx_t_3 = PyFloat_FromDouble(((__pyx_v_quantile / 1.) * (__pyx_v_nobs - 1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
          __pyx_t_3 = 0;

     1623:             output[i] = skiplist.get(idx)

          /* "pandas/algos.pyx":1623
     *         if nobs >= minp:
     *             idx = int((quantile / 1.) * (nobs - 1))
     *             output[i] = skiplist.get(idx)             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
          __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_3 = ((struct __pyx_vtabstruct_6pandas_5algos_IndexableSkiplist *)__pyx_v_skiplist->__pyx_vtab)->get(__pyx_v_skiplist, __pyx_t_15, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_16 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_15 < 0) {
            __pyx_t_15 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_15 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_t_16;
          goto __pyx_L11;
        }
        /*else*/ {

     1624:         else:

     1625:             output[i] = NaN

          /* "pandas/algos.pyx":1625
     *             output[i] = skiplist.get(idx)
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     return output
     */
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_8 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_8 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_8 = 0;
          if (unlikely(__pyx_t_8 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_8);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L11:;
      }

     1626:

     1627:     return output

      /* "pandas/algos.pyx":1627
     *             output[i] = NaN
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     * def roll_generic(ndarray[float64_t, cast=True] input, int win,
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1628:

     1629: def roll_generic(ndarray[float64_t, cast=True] input, int win,

    /* "pandas/algos.pyx":1629
     *     return output
     *
     * def roll_generic(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                  int minp, object func):
     *     cdef ndarray[double_t] output, counts, bufarr
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_53roll_generic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_53roll_generic = {__Pyx_NAMESTR("roll_generic"), (PyCFunction)__pyx_pw_6pandas_5algos_53roll_generic, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_53roll_generic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      int __pyx_v_win;
      int __pyx_v_minp;
      PyObject *__pyx_v_func = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_generic (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_win,&__pyx_n_s_minp,&__pyx_n_s_func,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_win)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_generic", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_generic", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_func)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_generic", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_generic") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_win = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_win == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_v_func = values[3];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_generic", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_52roll_generic(__pyx_self, __pyx_v_input, __pyx_v_win, __pyx_v_minp, __pyx_v_func);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_52roll_generic(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, int __pyx_v_win, int __pyx_v_minp, PyObject *__pyx_v_func) {
      PyArrayObject *__pyx_v_output = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_bufarr = 0;
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_n;
      __pyx_t_5numpy_float64_t *__pyx_v_buf;
      __pyx_t_5numpy_float64_t *__pyx_v_oldbuf;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_bufarr;
      __Pyx_Buffer __pyx_pybuffer_bufarr;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_generic", 0);
      __Pyx_INCREF((PyObject *)__pyx_v_input);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_bufarr.pybuffer.buf = NULL;
      __pyx_pybuffer_bufarr.refcount = 0;
      __pyx_pybuffernd_bufarr.data = NULL;
      __pyx_pybuffernd_bufarr.rcbuffer = &__pyx_pybuffer_bufarr;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 1, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1629
     *     return output
     *
     * def roll_generic(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                  int minp, object func):
     *     cdef ndarray[double_t] output, counts, bufarr
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_12);
      __Pyx_XDECREF(__pyx_t_13);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bufarr.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bufarr.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XDECREF((PyObject *)__pyx_v_counts);
      __Pyx_XDECREF((PyObject *)__pyx_v_bufarr);
      __Pyx_XDECREF((PyObject *)__pyx_v_input);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1629
     *     return output
     *
     * def roll_generic(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                  int minp, object func):
     *     cdef ndarray[double_t] output, counts, bufarr
     */
      __pyx_tuple__268 = PyTuple_Pack(11, __pyx_n_s_input, __pyx_n_s_win, __pyx_n_s_minp, __pyx_n_s_func, __pyx_n_s_output, __pyx_n_s_counts, __pyx_n_s_bufarr, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_buf, __pyx_n_s_oldbuf); if (unlikely(!__pyx_tuple__268)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__268);
      __Pyx_GIVEREF(__pyx_tuple__268);

      /* "pandas/algos.pyx":1629
     *     return output
     *
     * def roll_generic(ndarray[float64_t, cast=True] input, int win,             # <<<<<<<<<<<<<<
     *                  int minp, object func):
     *     cdef ndarray[double_t] output, counts, bufarr
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_53roll_generic, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_generic, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__269 = (PyObject*)__Pyx_PyCode_New(4, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__268, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_generic, 1629, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__269)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1630:                  int minp, object func):

     1631:     cdef ndarray[double_t] output, counts, bufarr

     1632:     cdef Py_ssize_t i, n

     1633:     cdef float64_t *buf, *oldbuf

     1634:

     1635:     if not input.flags.c_contiguous:

      /* "pandas/algos.pyx":1635
     *     cdef float64_t *buf, *oldbuf
     *
     *     if not input.flags.c_contiguous:             # <<<<<<<<<<<<<<
     *         input = input.copy('C')
     *
     */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_input), __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = ((!__pyx_t_3) != 0);
      if (__pyx_t_4) {

     1636:         input = input.copy('C')

        /* "pandas/algos.pyx":1636
     *
     *     if not input.flags.c_contiguous:
     *         input = input.copy('C')             # <<<<<<<<<<<<<<
     *
     *     buf = <float64_t*> input.data
     */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_input), __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 1, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 1, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            }
          }
          __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = 0;
        __Pyx_DECREF_SET(__pyx_v_input, ((PyArrayObject *)__pyx_t_1));
        __pyx_t_1 = 0;
        goto __pyx_L3;
      }
      __pyx_L3:;

      /* "pandas/algos.pyx":1636
     *
     *     if not input.flags.c_contiguous:
     *         input = input.copy('C')             # <<<<<<<<<<<<<<
     *
     *     buf = <float64_t*> input.data
     */
      __pyx_tuple__30 = PyTuple_Pack(1, __pyx_n_s_C); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__30);
      __Pyx_GIVEREF(__pyx_tuple__30);

     1637:

     1638:     buf = <float64_t*> input.data

      /* "pandas/algos.pyx":1638
     *         input = input.copy('C')
     *
     *     buf = <float64_t*> input.data             # <<<<<<<<<<<<<<
     *
     *     n = len(input)
     */
      __pyx_v_buf = ((__pyx_t_5numpy_float64_t *)__pyx_v_input->data);

     1639:

     1640:     n = len(input)

      /* "pandas/algos.pyx":1640
     *     buf = <float64_t*> input.data
     *
     *     n = len(input)             # <<<<<<<<<<<<<<
     *     if n == 0:
     *         return input
     */
      __pyx_t_10 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_10;

     1641:     if n == 0:

      /* "pandas/algos.pyx":1641
     *
     *     n = len(input)
     *     if n == 0:             # <<<<<<<<<<<<<<
     *         return input
     *
     */
      __pyx_t_4 = ((__pyx_v_n == 0) != 0);
      if (__pyx_t_4) {

     1642:         return input

        /* "pandas/algos.pyx":1642
     *     n = len(input)
     *     if n == 0:
     *         return input             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(win, minp, n)
     */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(((PyObject *)__pyx_v_input));
        __pyx_r = ((PyObject *)__pyx_v_input);
        goto __pyx_L0;
      }

     1643:

     1644:     minp = _check_minp(win, minp, n)

      /* "pandas/algos.pyx":1644
     *         return input
     *
     *     minp = _check_minp(win, minp, n)             # <<<<<<<<<<<<<<
     *     output = np.empty(n, dtype=float)
     *     counts = roll_sum(np.isfinite(input).astype(float), win, minp)
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_t_2 = 0;
      __pyx_t_11 = 0;
      __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_v_minp = __pyx_t_6;

     1645:     output = np.empty(n, dtype=float)

      /* "pandas/algos.pyx":1645
     *
     *     minp = _check_minp(win, minp, n)
     *     output = np.empty(n, dtype=float)             # <<<<<<<<<<<<<<
     *     counts = roll_sum(np.isfinite(input).astype(float), win, minp)
     *
     */
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = PyObject_Call(__pyx_t_13, __pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_11);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
          }
        }
        __pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_11);
      __pyx_t_11 = 0;

     1646:     counts = roll_sum(np.isfinite(input).astype(float), win, minp)

      /* "pandas/algos.pyx":1646
     *     minp = _check_minp(win, minp, n)
     *     output = np.empty(n, dtype=float)
     *     counts = roll_sum(np.isfinite(input).astype(float), win, minp)             # <<<<<<<<<<<<<<
     *
     *     bufarr = np.empty(win, dtype=float)
     */
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_roll_sum); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_isfinite); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(((PyObject *)__pyx_v_input));
      PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_v_input));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_input));
      __pyx_t_13 = PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_astype); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(((PyObject *)((PyObject*)(&PyFloat_Type))));
      PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)(&PyFloat_Type))));
      __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyFloat_Type))));
      __pyx_t_1 = PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_t_1 = 0;
      __pyx_t_13 = 0;
      __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          }
        }
        __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_counts = ((PyArrayObject *)__pyx_t_12);
      __pyx_t_12 = 0;

     1647:

     1648:     bufarr = np.empty(win, dtype=float)

      /* "pandas/algos.pyx":1648
     *     counts = roll_sum(np.isfinite(input).astype(float), win, minp)
     *
     *     bufarr = np.empty(win, dtype=float)             # <<<<<<<<<<<<<<
     *     oldbuf = <float64_t*> bufarr.data
     *
     */
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_win); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = PyObject_Call(__pyx_t_2, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_13);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bufarr.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bufarr.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bufarr.rcbuffer->pybuffer, (PyObject*)__pyx_v_bufarr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
          }
        }
        __pyx_pybuffernd_bufarr.diminfo[0].strides = __pyx_pybuffernd_bufarr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bufarr.diminfo[0].shape = __pyx_pybuffernd_bufarr.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_14 = 0;
      __pyx_v_bufarr = ((PyArrayObject *)__pyx_t_13);
      __pyx_t_13 = 0;

     1649:     oldbuf = <float64_t*> bufarr.data

      /* "pandas/algos.pyx":1649
     *
     *     bufarr = np.empty(win, dtype=float)
     *     oldbuf = <float64_t*> bufarr.data             # <<<<<<<<<<<<<<
     *
     *     n = len(input)
     */
      __pyx_v_oldbuf = ((__pyx_t_5numpy_float64_t *)__pyx_v_bufarr->data);

     1650:

     1651:     n = len(input)

      /* "pandas/algos.pyx":1651
     *     oldbuf = <float64_t*> bufarr.data
     *
     *     n = len(input)             # <<<<<<<<<<<<<<
     *     for i from 0 <= i < int_min(win, n):
     *         if counts[i] >= minp:
     */
      __pyx_t_10 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_10;

     1652:     for i from 0 <= i < int_min(win, n):

      /* "pandas/algos.pyx":1652
     *
     *     n = len(input)
     *     for i from 0 <= i < int_min(win, n):             # <<<<<<<<<<<<<<
     *         if counts[i] >= minp:
     *             output[i] = func(input[int_max(i - win + 1, 0) : i + 1])
     */
      __pyx_t_6 = __pyx_f_6pandas_5algos_int_min(__pyx_v_win, __pyx_v_n);
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

     1653:         if counts[i] >= minp:

        /* "pandas/algos.pyx":1653
     *     n = len(input)
     *     for i from 0 <= i < int_min(win, n):
     *         if counts[i] >= minp:             # <<<<<<<<<<<<<<
     *             output[i] = func(input[int_max(i - win + 1, 0) : i + 1])
     *         else:
     */
        __pyx_t_10 = __pyx_v_i;
        __pyx_t_15 = -1;
        if (__pyx_t_10 < 0) {
          __pyx_t_10 += __pyx_pybuffernd_counts.diminfo[0].shape;
          if (unlikely(__pyx_t_10 < 0)) __pyx_t_15 = 0;
        } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_counts.diminfo[0].shape)) __pyx_t_15 = 0;
        if (unlikely(__pyx_t_15 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_15);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_4 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_counts.diminfo[0].strides)) >= __pyx_v_minp) != 0);
        if (__pyx_t_4) {

     1654:             output[i] = func(input[int_max(i - win + 1, 0) : i + 1])

          /* "pandas/algos.pyx":1654
     *     for i from 0 <= i < int_min(win, n):
     *         if counts[i] >= minp:
     *             output[i] = func(input[int_max(i - win + 1, 0) : i + 1])             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
          __pyx_t_13 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_input), __pyx_f_6pandas_5algos_int_max(((__pyx_v_i - __pyx_v_win) + 1), 0), (__pyx_v_i + 1), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;
          __pyx_t_13 = PyObject_Call(__pyx_v_func, __pyx_t_12, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_13); if (unlikely((__pyx_t_16 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_15 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_15 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_15 = 0;
          if (unlikely(__pyx_t_15 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_15);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_t_16;
          goto __pyx_L7;
        }
        /*else*/ {

     1655:         else:

     1656:             output[i] = NaN

          /* "pandas/algos.pyx":1656
     *             output[i] = func(input[int_max(i - win + 1, 0) : i + 1])
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     for i from win <= i < n:
     */
          __pyx_t_18 = __pyx_v_i;
          __pyx_t_15 = -1;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_15 = 0;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_15 = 0;
          if (unlikely(__pyx_t_15 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_15);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L7:;
      }

     1657:

     1658:     for i from win <= i < n:

      /* "pandas/algos.pyx":1658
     *             output[i] = NaN
     *
     *     for i from win <= i < n:             # <<<<<<<<<<<<<<
     *         buf = buf + 1
     *         bufarr.data = <char*> buf
     */
      __pyx_t_19 = __pyx_v_n;
      for (__pyx_v_i = __pyx_v_win; __pyx_v_i < __pyx_t_19; __pyx_v_i++) {

     1659:         buf = buf + 1

        /* "pandas/algos.pyx":1659
     *
     *     for i from win <= i < n:
     *         buf = buf + 1             # <<<<<<<<<<<<<<
     *         bufarr.data = <char*> buf
     *         if counts[i] >= minp:
     */
        __pyx_v_buf = (__pyx_v_buf + 1);

     1660:         bufarr.data = <char*> buf

        /* "pandas/algos.pyx":1660
     *     for i from win <= i < n:
     *         buf = buf + 1
     *         bufarr.data = <char*> buf             # <<<<<<<<<<<<<<
     *         if counts[i] >= minp:
     *             output[i] = func(bufarr)
     */
        __pyx_v_bufarr->data = ((char *)__pyx_v_buf);

     1661:         if counts[i] >= minp:

        /* "pandas/algos.pyx":1661
     *         buf = buf + 1
     *         bufarr.data = <char*> buf
     *         if counts[i] >= minp:             # <<<<<<<<<<<<<<
     *             output[i] = func(bufarr)
     *         else:
     */
        __pyx_t_20 = __pyx_v_i;
        __pyx_t_6 = -1;
        if (__pyx_t_20 < 0) {
          __pyx_t_20 += __pyx_pybuffernd_counts.diminfo[0].shape;
          if (unlikely(__pyx_t_20 < 0)) __pyx_t_6 = 0;
        } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_counts.diminfo[0].shape)) __pyx_t_6 = 0;
        if (unlikely(__pyx_t_6 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_6);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_4 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_counts.diminfo[0].strides)) >= __pyx_v_minp) != 0);
        if (__pyx_t_4) {

     1662:             output[i] = func(bufarr)

          /* "pandas/algos.pyx":1662
     *         bufarr.data = <char*> buf
     *         if counts[i] >= minp:
     *             output[i] = func(bufarr)             # <<<<<<<<<<<<<<
     *         else:
     *             output[i] = NaN
     */
          __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_INCREF(((PyObject *)__pyx_v_bufarr));
          PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_v_bufarr));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_bufarr));
          __pyx_t_12 = PyObject_Call(__pyx_v_func, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_16 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_21 = __pyx_v_i;
          __pyx_t_6 = -1;
          if (__pyx_t_21 < 0) {
            __pyx_t_21 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_21 < 0)) __pyx_t_6 = 0;
          } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_6 = 0;
          if (unlikely(__pyx_t_6 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_6);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_t_16;
          goto __pyx_L10;
        }
        /*else*/ {

     1663:         else:

     1664:             output[i] = NaN

          /* "pandas/algos.pyx":1664
     *             output[i] = func(bufarr)
     *         else:
     *             output[i] = NaN             # <<<<<<<<<<<<<<
     *
     *     bufarr.data = <char*> oldbuf
     */
          __pyx_t_22 = __pyx_v_i;
          __pyx_t_6 = -1;
          if (__pyx_t_22 < 0) {
            __pyx_t_22 += __pyx_pybuffernd_output.diminfo[0].shape;
            if (unlikely(__pyx_t_22 < 0)) __pyx_t_6 = 0;
          } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_6 = 0;
          if (unlikely(__pyx_t_6 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_6);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
        }
        __pyx_L10:;
      }

     1665:

     1666:     bufarr.data = <char*> oldbuf

      /* "pandas/algos.pyx":1666
     *             output[i] = NaN
     *
     *     bufarr.data = <char*> oldbuf             # <<<<<<<<<<<<<<
     *
     *     return output
     */
      __pyx_v_bufarr->data = ((char *)__pyx_v_oldbuf);

     1667:

     1668:     return output

      /* "pandas/algos.pyx":1668
     *     bufarr.data = <char*> oldbuf
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1669:

     1670:

     1671: def roll_window(ndarray[float64_t, ndim=1, cast=True] input,

    /* "pandas/algos.pyx":1671
     *
     *
     * def roll_window(ndarray[float64_t, ndim=1, cast=True] input,             # <<<<<<<<<<<<<<
     *                 ndarray[float64_t, ndim=1, cast=True] weights,
     *                 int minp, bint avg=True, bint avg_wgt=False):
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_55roll_window(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_54roll_window[] = "\n    Assume len(weights) << len(input)\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_55roll_window = {__Pyx_NAMESTR("roll_window"), (PyCFunction)__pyx_pw_6pandas_5algos_55roll_window, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_54roll_window)};
    static PyObject *__pyx_pw_6pandas_5algos_55roll_window(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_input = 0;
      PyArrayObject *__pyx_v_weights = 0;
      int __pyx_v_minp;
      int __pyx_v_avg;
      int __pyx_v_avg_wgt;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_window (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_weights,&__pyx_n_s_minp,&__pyx_n_s_avg,&__pyx_n_s_avg_wgt,0};
        PyObject* values[5] = {0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_window", 0, 3, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minp)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("roll_window", 0, 3, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_avg);
              if (value) { values[3] = value; kw_args--; }
            }
            case  4:
            if (kw_args > 0) {
              PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_avg_wgt);
              if (value) { values[4] = value; kw_args--; }
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "roll_window") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else {
          switch (PyTuple_GET_SIZE(__pyx_args)) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_input = ((PyArrayObject *)values[0]);
        __pyx_v_weights = ((PyArrayObject *)values[1]);
        __pyx_v_minp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        if (values[3]) {
          __pyx_v_avg = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_avg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        } else {

      /* "pandas/algos.pyx":1671
     *
     *
     * def roll_window(ndarray[float64_t, ndim=1, cast=True] input,             # <<<<<<<<<<<<<<
     *                 ndarray[float64_t, ndim=1, cast=True] weights,
     *                 int minp, bint avg=True, bint avg_wgt=False):
     */

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_54roll_window(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_input, PyArrayObject *__pyx_v_weights, int __pyx_v_minp, int __pyx_v_avg, int __pyx_v_avg_wgt) {
      PyArrayObject *__pyx_v_output = 0;
      PyArrayObject *__pyx_v_tot_wgt = 0;
      PyArrayObject *__pyx_v_counts = 0;
      Py_ssize_t __pyx_v_in_i;
      Py_ssize_t __pyx_v_win_i;
      Py_ssize_t __pyx_v_win_n;
      Py_ssize_t __pyx_v_in_n;
      __pyx_t_5numpy_float64_t __pyx_v_val_in;
      __pyx_t_5numpy_float64_t __pyx_v_val_win;
      __pyx_t_5numpy_float64_t __pyx_v_c;
      __pyx_t_5numpy_float64_t __pyx_v_w;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_input;
      __Pyx_Buffer __pyx_pybuffer_input;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_output;
      __Pyx_Buffer __pyx_pybuffer_output;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_tot_wgt;
      __Pyx_Buffer __pyx_pybuffer_tot_wgt;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_weights;
      __Pyx_Buffer __pyx_pybuffer_weights;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("roll_window", 0);
      __pyx_pybuffer_output.pybuffer.buf = NULL;
      __pyx_pybuffer_output.refcount = 0;
      __pyx_pybuffernd_output.data = NULL;
      __pyx_pybuffernd_output.rcbuffer = &__pyx_pybuffer_output;
      __pyx_pybuffer_tot_wgt.pybuffer.buf = NULL;
      __pyx_pybuffer_tot_wgt.refcount = 0;
      __pyx_pybuffernd_tot_wgt.data = NULL;
      __pyx_pybuffernd_tot_wgt.rcbuffer = &__pyx_pybuffer_tot_wgt;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_input.pybuffer.buf = NULL;
      __pyx_pybuffer_input.refcount = 0;
      __pyx_pybuffernd_input.data = NULL;
      __pyx_pybuffernd_input.rcbuffer = &__pyx_pybuffer_input;
      __pyx_pybuffer_weights.pybuffer.buf = NULL;
      __pyx_pybuffer_weights.refcount = 0;
      __pyx_pybuffernd_weights.data = NULL;
      __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input.rcbuffer->pybuffer, (PyObject*)__pyx_v_input, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 1, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_input.diminfo[0].strides = __pyx_pybuffernd_input.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input.diminfo[0].shape = __pyx_pybuffernd_input.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 1, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1671
     *
     *
     * def roll_window(ndarray[float64_t, ndim=1, cast=True] input,             # <<<<<<<<<<<<<<
     *                 ndarray[float64_t, ndim=1, cast=True] weights,
     *                 int minp, bint avg=True, bint avg_wgt=False):
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_12);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.roll_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_output);
      __Pyx_XDECREF((PyObject *)__pyx_v_tot_wgt);
      __Pyx_XDECREF((PyObject *)__pyx_v_counts);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1671
     *
     *
     * def roll_window(ndarray[float64_t, ndim=1, cast=True] input,             # <<<<<<<<<<<<<<
     *                 ndarray[float64_t, ndim=1, cast=True] weights,
     *                 int minp, bint avg=True, bint avg_wgt=False):
     */
      __pyx_tuple__270 = PyTuple_Pack(18, __pyx_n_s_input, __pyx_n_s_weights, __pyx_n_s_minp, __pyx_n_s_avg, __pyx_n_s_avg_wgt, __pyx_n_s_output, __pyx_n_s_tot_wgt, __pyx_n_s_counts, __pyx_n_s_in_i, __pyx_n_s_win_i, __pyx_n_s_win_n, __pyx_n_s_win_k, __pyx_n_s_in_n, __pyx_n_s_in_k, __pyx_n_s_val_in, __pyx_n_s_val_win, __pyx_n_s_c, __pyx_n_s_w); if (unlikely(!__pyx_tuple__270)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__270);
      __Pyx_GIVEREF(__pyx_tuple__270);

      /* "pandas/algos.pyx":1671
     *
     *
     * def roll_window(ndarray[float64_t, ndim=1, cast=True] input,             # <<<<<<<<<<<<<<
     *                 ndarray[float64_t, ndim=1, cast=True] weights,
     *                 int minp, bint avg=True, bint avg_wgt=False):
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_55roll_window, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_roll_window, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__271 = (PyObject*)__Pyx_PyCode_New(5, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__270, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_roll_window, 1671, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__271)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1672:                 ndarray[float64_t, ndim=1, cast=True] weights,

     1673:                 int minp, bint avg=True, bint avg_wgt=False):

          /* "pandas/algos.pyx":1673
     * def roll_window(ndarray[float64_t, ndim=1, cast=True] input,
     *                 ndarray[float64_t, ndim=1, cast=True] weights,
     *                 int minp, bint avg=True, bint avg_wgt=False):             # <<<<<<<<<<<<<<
     *     """
     *     Assume len(weights) << len(input)
     */
          __pyx_v_avg = ((int)1);
        }
        if (values[4]) {
          __pyx_v_avg_wgt = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_avg_wgt == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        } else {
          __pyx_v_avg_wgt = ((int)0);
        }
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("roll_window", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.roll_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weights), __pyx_ptype_5numpy_ndarray, 1, "weights", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_54roll_window(__pyx_self, __pyx_v_input, __pyx_v_weights, __pyx_v_minp, __pyx_v_avg, __pyx_v_avg_wgt);

     1674:     """

     1675:     Assume len(weights) << len(input)

     1676:     """

     1677:     cdef:

     1678:         ndarray[double_t] output, tot_wgt, counts

     1679:         Py_ssize_t in_i, win_i, win_n, win_k, in_n, in_k

     1680:         float64_t val_in, val_win, c, w

     1681:

     1682:     in_n = len(input)

      /* "pandas/algos.pyx":1682
     *         float64_t val_in, val_win, c, w
     *
     *     in_n = len(input)             # <<<<<<<<<<<<<<
     *     win_n = len(weights)
     *     output = np.zeros(in_n, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_input)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_in_n = __pyx_t_1;

     1683:     win_n = len(weights)

      /* "pandas/algos.pyx":1683
     *
     *     in_n = len(input)
     *     win_n = len(weights)             # <<<<<<<<<<<<<<
     *     output = np.zeros(in_n, dtype=float)
     *     counts = np.zeros(in_n, dtype=float)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_weights)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_win_n = __pyx_t_1;

     1684:     output = np.zeros(in_n, dtype=float)

      /* "pandas/algos.pyx":1684
     *     in_n = len(input)
     *     win_n = len(weights)
     *     output = np.zeros(in_n, dtype=float)             # <<<<<<<<<<<<<<
     *     counts = np.zeros(in_n, dtype=float)
     *     if avg:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_in_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output.rcbuffer->pybuffer, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_output.diminfo[0].strides = __pyx_pybuffernd_output.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output.diminfo[0].shape = __pyx_pybuffernd_output.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_output = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1685:     counts = np.zeros(in_n, dtype=float)

      /* "pandas/algos.pyx":1685
     *     win_n = len(weights)
     *     output = np.zeros(in_n, dtype=float)
     *     counts = np.zeros(in_n, dtype=float)             # <<<<<<<<<<<<<<
     *     if avg:
     *         tot_wgt = np.zeros(in_n, dtype=float)
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_in_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_counts = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;

     1686:     if avg:

      /* "pandas/algos.pyx":1686
     *     output = np.zeros(in_n, dtype=float)
     *     counts = np.zeros(in_n, dtype=float)
     *     if avg:             # <<<<<<<<<<<<<<
     *         tot_wgt = np.zeros(in_n, dtype=float)
     *
     */
      __pyx_t_11 = (__pyx_v_avg != 0);
      if (__pyx_t_11) {

     1687:         tot_wgt = np.zeros(in_n, dtype=float)

        /* "pandas/algos.pyx":1687
     *     counts = np.zeros(in_n, dtype=float)
     *     if avg:
     *         tot_wgt = np.zeros(in_n, dtype=float)             # <<<<<<<<<<<<<<
     *
     *     minp = _check_minp(len(weights), minp, in_n)
     */
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_in_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer);
          __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_7 < 0)) {
            PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer, (PyObject*)__pyx_v_tot_wgt, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
            }
          }
          __pyx_pybuffernd_tot_wgt.diminfo[0].strides = __pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tot_wgt.diminfo[0].shape = __pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = 0;
        __pyx_v_tot_wgt = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L3;
      }
      __pyx_L3:;

     1688:

     1689:     minp = _check_minp(len(weights), minp, in_n)

      /* "pandas/algos.pyx":1689
     *         tot_wgt = np.zeros(in_n, dtype=float)
     *
     *     minp = _check_minp(len(weights), minp, in_n)             # <<<<<<<<<<<<<<
     *
     *     if avg_wgt:
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_minp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_weights)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_minp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_in_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_minp = __pyx_t_7;

     1690:

     1691:     if avg_wgt:

      /* "pandas/algos.pyx":1691
     *     minp = _check_minp(len(weights), minp, in_n)
     *
     *     if avg_wgt:             # <<<<<<<<<<<<<<
     *         for win_i from 0 <= win_i < win_n:
     *             val_win = weights[win_i]
     */
      __pyx_t_11 = (__pyx_v_avg_wgt != 0);
      if (__pyx_t_11) {

     1692:         for win_i from 0 <= win_i < win_n:

        /* "pandas/algos.pyx":1692
     *
     *     if avg_wgt:
     *         for win_i from 0 <= win_i < win_n:             # <<<<<<<<<<<<<<
     *             val_win = weights[win_i]
     *             if val_win != val_win:
     */
        __pyx_t_1 = __pyx_v_win_n;
        for (__pyx_v_win_i = 0; __pyx_v_win_i < __pyx_t_1; __pyx_v_win_i++) {

     1693:             val_win = weights[win_i]

          /* "pandas/algos.pyx":1693
     *     if avg_wgt:
     *         for win_i from 0 <= win_i < win_n:
     *             val_win = weights[win_i]             # <<<<<<<<<<<<<<
     *             if val_win != val_win:
     *                 continue
     */
          __pyx_t_13 = __pyx_v_win_i;
          __pyx_t_7 = -1;
          if (__pyx_t_13 < 0) {
            __pyx_t_13 += __pyx_pybuffernd_weights.diminfo[0].shape;
            if (unlikely(__pyx_t_13 < 0)) __pyx_t_7 = 0;
          } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_weights.diminfo[0].shape)) __pyx_t_7 = 0;
          if (unlikely(__pyx_t_7 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_7);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_val_win = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_weights.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_weights.diminfo[0].strides));

     1694:             if val_win != val_win:

          /* "pandas/algos.pyx":1694
     *         for win_i from 0 <= win_i < win_n:
     *             val_win = weights[win_i]
     *             if val_win != val_win:             # <<<<<<<<<<<<<<
     *                 continue
     *
     */
          __pyx_t_11 = ((__pyx_v_val_win != __pyx_v_val_win) != 0);
          if (__pyx_t_11) {

     1695:                 continue

            /* "pandas/algos.pyx":1695
     *             val_win = weights[win_i]
     *             if val_win != val_win:
     *                 continue             # <<<<<<<<<<<<<<
     *
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:
     */
            goto __pyx_L5_continue;
          }

     1696:

     1697:             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:

          /* "pandas/algos.pyx":1697
     *                 continue
     *
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:             # <<<<<<<<<<<<<<
     *                 val_in = input[in_i]
     *                 if val_in == val_in:
     */
          __pyx_t_14 = ((__pyx_v_in_n - (__pyx_v_win_n - __pyx_v_win_i)) + 1);
          for (__pyx_v_in_i = 0; __pyx_v_in_i < __pyx_t_14; __pyx_v_in_i++) {

     1698:                 val_in = input[in_i]

            /* "pandas/algos.pyx":1698
     *
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:
     *                 val_in = input[in_i]             # <<<<<<<<<<<<<<
     *                 if val_in == val_in:
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win
     */
            __pyx_t_15 = __pyx_v_in_i;
            __pyx_t_7 = -1;
            if (__pyx_t_15 < 0) {
              __pyx_t_15 += __pyx_pybuffernd_input.diminfo[0].shape;
              if (unlikely(__pyx_t_15 < 0)) __pyx_t_7 = 0;
            } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_7 = 0;
            if (unlikely(__pyx_t_7 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_7);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_val_in = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_input.diminfo[0].strides));

     1699:                 if val_in == val_in:

            /* "pandas/algos.pyx":1699
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:
     *                 val_in = input[in_i]
     *                 if val_in == val_in:             # <<<<<<<<<<<<<<
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win
     *                     counts[in_i + (win_n - win_i) - 1] += 1
     */
            __pyx_t_11 = ((__pyx_v_val_in == __pyx_v_val_in) != 0);
            if (__pyx_t_11) {

     1700:                     output[in_i + (win_n - win_i) - 1] += val_in * val_win

              /* "pandas/algos.pyx":1700
     *                 val_in = input[in_i]
     *                 if val_in == val_in:
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win             # <<<<<<<<<<<<<<
     *                     counts[in_i + (win_n - win_i) - 1] += 1
     *                     tot_wgt[in_i + (win_n - win_i) - 1] += val_win
     */
              __pyx_t_16 = ((__pyx_v_in_i + (__pyx_v_win_n - __pyx_v_win_i)) - 1);
              __pyx_t_7 = -1;
              if (__pyx_t_16 < 0) {
                __pyx_t_16 += __pyx_pybuffernd_output.diminfo[0].shape;
                if (unlikely(__pyx_t_16 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_output.diminfo[0].strides) += (__pyx_v_val_in * __pyx_v_val_win);

     1701:                     counts[in_i + (win_n - win_i) - 1] += 1

              /* "pandas/algos.pyx":1701
     *                 if val_in == val_in:
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win
     *                     counts[in_i + (win_n - win_i) - 1] += 1             # <<<<<<<<<<<<<<
     *                     tot_wgt[in_i + (win_n - win_i) - 1] += val_win
     *
     */
              __pyx_t_17 = ((__pyx_v_in_i + (__pyx_v_win_n - __pyx_v_win_i)) - 1);
              __pyx_t_7 = -1;
              if (__pyx_t_17 < 0) {
                __pyx_t_17 += __pyx_pybuffernd_counts.diminfo[0].shape;
                if (unlikely(__pyx_t_17 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_counts.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_counts.diminfo[0].strides) += 1.0;

     1702:                     tot_wgt[in_i + (win_n - win_i) - 1] += val_win

              /* "pandas/algos.pyx":1702
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win
     *                     counts[in_i + (win_n - win_i) - 1] += 1
     *                     tot_wgt[in_i + (win_n - win_i) - 1] += val_win             # <<<<<<<<<<<<<<
     *
     *         for in_i from 0 <= in_i < in_n:
     */
              __pyx_t_18 = ((__pyx_v_in_i + (__pyx_v_win_n - __pyx_v_win_i)) - 1);
              __pyx_t_7 = -1;
              if (__pyx_t_18 < 0) {
                __pyx_t_18 += __pyx_pybuffernd_tot_wgt.diminfo[0].shape;
                if (unlikely(__pyx_t_18 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_tot_wgt.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_tot_wgt.diminfo[0].strides) += __pyx_v_val_win;
              goto __pyx_L10;
            }
            __pyx_L10:;
          }
          __pyx_L5_continue:;
        }

     1703:

     1704:         for in_i from 0 <= in_i < in_n:

        /* "pandas/algos.pyx":1704
     *                     tot_wgt[in_i + (win_n - win_i) - 1] += val_win
     *
     *         for in_i from 0 <= in_i < in_n:             # <<<<<<<<<<<<<<
     *             c = counts[in_i]
     *             if c < minp:
     */
        __pyx_t_1 = __pyx_v_in_n;
        for (__pyx_v_in_i = 0; __pyx_v_in_i < __pyx_t_1; __pyx_v_in_i++) {

     1705:             c = counts[in_i]

          /* "pandas/algos.pyx":1705
     *
     *         for in_i from 0 <= in_i < in_n:
     *             c = counts[in_i]             # <<<<<<<<<<<<<<
     *             if c < minp:
     *                 output[in_i] = NaN
     */
          __pyx_t_14 = __pyx_v_in_i;
          __pyx_t_7 = -1;
          if (__pyx_t_14 < 0) {
            __pyx_t_14 += __pyx_pybuffernd_counts.diminfo[0].shape;
            if (unlikely(__pyx_t_14 < 0)) __pyx_t_7 = 0;
          } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_counts.diminfo[0].shape)) __pyx_t_7 = 0;
          if (unlikely(__pyx_t_7 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_7);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_c = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_counts.diminfo[0].strides));

     1706:             if c < minp:

          /* "pandas/algos.pyx":1706
     *         for in_i from 0 <= in_i < in_n:
     *             c = counts[in_i]
     *             if c < minp:             # <<<<<<<<<<<<<<
     *                 output[in_i] = NaN
     *             else:
     */
          __pyx_t_11 = ((__pyx_v_c < __pyx_v_minp) != 0);
          if (__pyx_t_11) {

     1707:                 output[in_i] = NaN

            /* "pandas/algos.pyx":1707
     *             c = counts[in_i]
     *             if c < minp:
     *                 output[in_i] = NaN             # <<<<<<<<<<<<<<
     *             else:
     *                 w = tot_wgt[in_i]
     */
            __pyx_t_19 = __pyx_v_in_i;
            __pyx_t_7 = -1;
            if (__pyx_t_19 < 0) {
              __pyx_t_19 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_19 < 0)) __pyx_t_7 = 0;
            } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
            if (unlikely(__pyx_t_7 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_7);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
            goto __pyx_L13;
          }
          /*else*/ {

     1708:             else:

     1709:                 w = tot_wgt[in_i]

            /* "pandas/algos.pyx":1709
     *                 output[in_i] = NaN
     *             else:
     *                 w = tot_wgt[in_i]             # <<<<<<<<<<<<<<
     *                 if w == 0:
     *                     output[in_i] = NaN
     */
            __pyx_t_20 = __pyx_v_in_i;
            __pyx_t_7 = -1;
            if (__pyx_t_20 < 0) {
              __pyx_t_20 += __pyx_pybuffernd_tot_wgt.diminfo[0].shape;
              if (unlikely(__pyx_t_20 < 0)) __pyx_t_7 = 0;
            } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_tot_wgt.diminfo[0].shape)) __pyx_t_7 = 0;
            if (unlikely(__pyx_t_7 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_7);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_w = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_tot_wgt.diminfo[0].strides));

     1710:                 if w == 0:

            /* "pandas/algos.pyx":1710
     *             else:
     *                 w = tot_wgt[in_i]
     *                 if w == 0:             # <<<<<<<<<<<<<<
     *                     output[in_i] = NaN
     *                 else:
     */
            __pyx_t_11 = ((__pyx_v_w == 0.0) != 0);
            if (__pyx_t_11) {

     1711:                     output[in_i] = NaN

              /* "pandas/algos.pyx":1711
     *                 w = tot_wgt[in_i]
     *                 if w == 0:
     *                     output[in_i] = NaN             # <<<<<<<<<<<<<<
     *                 else:
     *                     output[in_i] /= tot_wgt[in_i]
     */
              __pyx_t_21 = __pyx_v_in_i;
              __pyx_t_7 = -1;
              if (__pyx_t_21 < 0) {
                __pyx_t_21 += __pyx_pybuffernd_output.diminfo[0].shape;
                if (unlikely(__pyx_t_21 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
              goto __pyx_L14;
            }
            /*else*/ {

     1712:                 else:

     1713:                     output[in_i] /= tot_wgt[in_i]

              /* "pandas/algos.pyx":1713
     *                     output[in_i] = NaN
     *                 else:
     *                     output[in_i] /= tot_wgt[in_i]             # <<<<<<<<<<<<<<
     *
     *     else:
     */
              __pyx_t_22 = __pyx_v_in_i;
              __pyx_t_7 = -1;
              if (__pyx_t_22 < 0) {
                __pyx_t_22 += __pyx_pybuffernd_tot_wgt.diminfo[0].shape;
                if (unlikely(__pyx_t_22 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_tot_wgt.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_23 = __pyx_v_in_i;
              __pyx_t_7 = -1;
              if (__pyx_t_23 < 0) {
                __pyx_t_23 += __pyx_pybuffernd_output.diminfo[0].shape;
                if (unlikely(__pyx_t_23 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_output.diminfo[0].strides) /= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_tot_wgt.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_tot_wgt.diminfo[0].strides));
            }
            __pyx_L14:;
          }
          __pyx_L13:;
        }
        goto __pyx_L4;
      }
      /*else*/ {

     1714:

     1715:     else:

     1716:         for win_i from 0 <= win_i < win_n:

        /* "pandas/algos.pyx":1716
     *
     *     else:
     *         for win_i from 0 <= win_i < win_n:             # <<<<<<<<<<<<<<
     *             val_win = weights[win_i]
     *             if val_win != val_win:
     */
        __pyx_t_1 = __pyx_v_win_n;
        for (__pyx_v_win_i = 0; __pyx_v_win_i < __pyx_t_1; __pyx_v_win_i++) {

     1717:             val_win = weights[win_i]

          /* "pandas/algos.pyx":1717
     *     else:
     *         for win_i from 0 <= win_i < win_n:
     *             val_win = weights[win_i]             # <<<<<<<<<<<<<<
     *             if val_win != val_win:
     *                 continue
     */
          __pyx_t_24 = __pyx_v_win_i;
          __pyx_t_7 = -1;
          if (__pyx_t_24 < 0) {
            __pyx_t_24 += __pyx_pybuffernd_weights.diminfo[0].shape;
            if (unlikely(__pyx_t_24 < 0)) __pyx_t_7 = 0;
          } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_weights.diminfo[0].shape)) __pyx_t_7 = 0;
          if (unlikely(__pyx_t_7 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_7);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_val_win = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_weights.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_weights.diminfo[0].strides));

     1718:             if val_win != val_win:

          /* "pandas/algos.pyx":1718
     *         for win_i from 0 <= win_i < win_n:
     *             val_win = weights[win_i]
     *             if val_win != val_win:             # <<<<<<<<<<<<<<
     *                 continue
     *
     */
          __pyx_t_11 = ((__pyx_v_val_win != __pyx_v_val_win) != 0);
          if (__pyx_t_11) {

     1719:                 continue

            /* "pandas/algos.pyx":1719
     *             val_win = weights[win_i]
     *             if val_win != val_win:
     *                 continue             # <<<<<<<<<<<<<<
     *
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:
     */
            goto __pyx_L15_continue;
          }

     1720:

     1721:             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:

          /* "pandas/algos.pyx":1721
     *                 continue
     *
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:             # <<<<<<<<<<<<<<
     *                 val_in = input[in_i]
     *
     */
          __pyx_t_25 = ((__pyx_v_in_n - (__pyx_v_win_n - __pyx_v_win_i)) + 1);
          for (__pyx_v_in_i = 0; __pyx_v_in_i < __pyx_t_25; __pyx_v_in_i++) {

     1722:                 val_in = input[in_i]

            /* "pandas/algos.pyx":1722
     *
     *             for in_i from 0 <= in_i < in_n - (win_n - win_i) + 1:
     *                 val_in = input[in_i]             # <<<<<<<<<<<<<<
     *
     *                 if val_in == val_in:
     */
            __pyx_t_26 = __pyx_v_in_i;
            __pyx_t_7 = -1;
            if (__pyx_t_26 < 0) {
              __pyx_t_26 += __pyx_pybuffernd_input.diminfo[0].shape;
              if (unlikely(__pyx_t_26 < 0)) __pyx_t_7 = 0;
            } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_input.diminfo[0].shape)) __pyx_t_7 = 0;
            if (unlikely(__pyx_t_7 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_7);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_v_val_in = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_input.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_input.diminfo[0].strides));

     1723:

     1724:                 if val_in == val_in:

            /* "pandas/algos.pyx":1724
     *                 val_in = input[in_i]
     *
     *                 if val_in == val_in:             # <<<<<<<<<<<<<<
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win
     *                     counts[in_i + (win_n - win_i) - 1] += 1
     */
            __pyx_t_11 = ((__pyx_v_val_in == __pyx_v_val_in) != 0);
            if (__pyx_t_11) {

     1725:                     output[in_i + (win_n - win_i) - 1] += val_in * val_win

              /* "pandas/algos.pyx":1725
     *
     *                 if val_in == val_in:
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win             # <<<<<<<<<<<<<<
     *                     counts[in_i + (win_n - win_i) - 1] += 1
     *
     */
              __pyx_t_27 = ((__pyx_v_in_i + (__pyx_v_win_n - __pyx_v_win_i)) - 1);
              __pyx_t_7 = -1;
              if (__pyx_t_27 < 0) {
                __pyx_t_27 += __pyx_pybuffernd_output.diminfo[0].shape;
                if (unlikely(__pyx_t_27 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_output.diminfo[0].strides) += (__pyx_v_val_in * __pyx_v_val_win);

     1726:                     counts[in_i + (win_n - win_i) - 1] += 1

              /* "pandas/algos.pyx":1726
     *                 if val_in == val_in:
     *                     output[in_i + (win_n - win_i) - 1] += val_in * val_win
     *                     counts[in_i + (win_n - win_i) - 1] += 1             # <<<<<<<<<<<<<<
     *
     *         for in_i from 0 <= in_i < in_n:
     */
              __pyx_t_28 = ((__pyx_v_in_i + (__pyx_v_win_n - __pyx_v_win_i)) - 1);
              __pyx_t_7 = -1;
              if (__pyx_t_28 < 0) {
                __pyx_t_28 += __pyx_pybuffernd_counts.diminfo[0].shape;
                if (unlikely(__pyx_t_28 < 0)) __pyx_t_7 = 0;
              } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_counts.diminfo[0].shape)) __pyx_t_7 = 0;
              if (unlikely(__pyx_t_7 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_7);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_counts.diminfo[0].strides) += 1.0;
              goto __pyx_L20;
            }
            __pyx_L20:;
          }
          __pyx_L15_continue:;
        }

     1727:

     1728:         for in_i from 0 <= in_i < in_n:

        /* "pandas/algos.pyx":1728
     *                     counts[in_i + (win_n - win_i) - 1] += 1
     *
     *         for in_i from 0 <= in_i < in_n:             # <<<<<<<<<<<<<<
     *             c = counts[in_i]
     *             if c < minp:
     */
        __pyx_t_1 = __pyx_v_in_n;
        for (__pyx_v_in_i = 0; __pyx_v_in_i < __pyx_t_1; __pyx_v_in_i++) {

     1729:             c = counts[in_i]

          /* "pandas/algos.pyx":1729
     *
     *         for in_i from 0 <= in_i < in_n:
     *             c = counts[in_i]             # <<<<<<<<<<<<<<
     *             if c < minp:
     *                 output[in_i] = NaN
     */
          __pyx_t_25 = __pyx_v_in_i;
          __pyx_t_7 = -1;
          if (__pyx_t_25 < 0) {
            __pyx_t_25 += __pyx_pybuffernd_counts.diminfo[0].shape;
            if (unlikely(__pyx_t_25 < 0)) __pyx_t_7 = 0;
          } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_counts.diminfo[0].shape)) __pyx_t_7 = 0;
          if (unlikely(__pyx_t_7 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_7);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_c = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_counts.diminfo[0].strides));

     1730:             if c < minp:

          /* "pandas/algos.pyx":1730
     *         for in_i from 0 <= in_i < in_n:
     *             c = counts[in_i]
     *             if c < minp:             # <<<<<<<<<<<<<<
     *                 output[in_i] = NaN
     *             elif avg:
     */
          __pyx_t_11 = ((__pyx_v_c < __pyx_v_minp) != 0);
          if (__pyx_t_11) {

     1731:                 output[in_i] = NaN

            /* "pandas/algos.pyx":1731
     *             c = counts[in_i]
     *             if c < minp:
     *                 output[in_i] = NaN             # <<<<<<<<<<<<<<
     *             elif avg:
     *                 output[in_i] /= c
     */
            __pyx_t_29 = __pyx_v_in_i;
            __pyx_t_7 = -1;
            if (__pyx_t_29 < 0) {
              __pyx_t_29 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_29 < 0)) __pyx_t_7 = 0;
            } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
            if (unlikely(__pyx_t_7 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_7);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_output.diminfo[0].strides) = __pyx_v_6pandas_5algos_NaN;
            goto __pyx_L23;
          }

     1732:             elif avg:

          /* "pandas/algos.pyx":1732
     *             if c < minp:
     *                 output[in_i] = NaN
     *             elif avg:             # <<<<<<<<<<<<<<
     *                 output[in_i] /= c
     *
     */
          __pyx_t_11 = (__pyx_v_avg != 0);
          if (__pyx_t_11) {

     1733:                 output[in_i] /= c

            /* "pandas/algos.pyx":1733
     *                 output[in_i] = NaN
     *             elif avg:
     *                 output[in_i] /= c             # <<<<<<<<<<<<<<
     *
     *     return output
     */
            __pyx_t_30 = __pyx_v_in_i;
            __pyx_t_7 = -1;
            if (__pyx_t_30 < 0) {
              __pyx_t_30 += __pyx_pybuffernd_output.diminfo[0].shape;
              if (unlikely(__pyx_t_30 < 0)) __pyx_t_7 = 0;
            } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_output.diminfo[0].shape)) __pyx_t_7 = 0;
            if (unlikely(__pyx_t_7 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_7);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_double_t *, __pyx_pybuffernd_output.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_output.diminfo[0].strides) /= __pyx_v_c;
            goto __pyx_L23;
          }
          __pyx_L23:;
        }
      }
      __pyx_L4:;

     1734:

     1735:     return output

      /* "pandas/algos.pyx":1735
     *                 output[in_i] /= c
     *
     *     return output             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_output));
      __pyx_r = ((PyObject *)__pyx_v_output);
      goto __pyx_L0;

     1736:

     1737:

     1738: #----------------------------------------------------------------------

     1739: # group operations

     1740:

     1741:

     1742: @cython.wraparound(False)

     1743: @cython.boundscheck(False)

     1744: def is_lexsorted(list list_of_arrays):

    /* "pandas/algos.pyx":1744
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def is_lexsorted(list list_of_arrays):             # <<<<<<<<<<<<<<
     *     cdef:
     *         int i
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_57is_lexsorted(PyObject *__pyx_self, PyObject *__pyx_v_list_of_arrays); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_57is_lexsorted = {__Pyx_NAMESTR("is_lexsorted"), (PyCFunction)__pyx_pw_6pandas_5algos_57is_lexsorted, METH_O, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_57is_lexsorted(PyObject *__pyx_self, PyObject *__pyx_v_list_of_arrays) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("is_lexsorted (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_list_of_arrays), (&PyList_Type), 1, "list_of_arrays", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_56is_lexsorted(__pyx_self, ((PyObject*)__pyx_v_list_of_arrays));
      CYTHON_UNUSED int __pyx_lineno = 0;
      CYTHON_UNUSED const char *__pyx_filename = NULL;
      CYTHON_UNUSED int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_56is_lexsorted(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_of_arrays) {
      int __pyx_v_i;
      Py_ssize_t __pyx_v_n;
      Py_ssize_t __pyx_v_nlevels;
      __pyx_t_5numpy_int64_t __pyx_v_k;
      __pyx_t_5numpy_int64_t __pyx_v_cur;
      __pyx_t_5numpy_int64_t __pyx_v_pre;
      PyArrayObject *__pyx_v_arr = 0;
      __pyx_t_5numpy_int64_t **__pyx_v_vecs;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("is_lexsorted", 0);

      /* "pandas/algos.pyx":1744
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def is_lexsorted(list list_of_arrays):             # <<<<<<<<<<<<<<
     *     cdef:
     *         int i
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("pandas.algos.is_lexsorted", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF((PyObject *)__pyx_v_arr);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1744
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def is_lexsorted(list list_of_arrays):             # <<<<<<<<<<<<<<
     *     cdef:
     *         int i
     */
      __pyx_tuple__272 = PyTuple_Pack(9, __pyx_n_s_list_of_arrays, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_nlevels, __pyx_n_s_k, __pyx_n_s_cur, __pyx_n_s_pre, __pyx_n_s_arr, __pyx_n_s_vecs); if (unlikely(!__pyx_tuple__272)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__272);
      __Pyx_GIVEREF(__pyx_tuple__272);

      /* "pandas/algos.pyx":1744
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def is_lexsorted(list list_of_arrays):             # <<<<<<<<<<<<<<
     *     cdef:
     *         int i
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_57is_lexsorted, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_lexsorted, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__273 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__272, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_is_lexsorted, 1744, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__273)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1745:     cdef:

     1746:         int i

     1747:         Py_ssize_t n, nlevels

     1748:         int64_t k, cur, pre

     1749:         ndarray arr

     1750:

     1751:     nlevels = len(list_of_arrays)

      /* "pandas/algos.pyx":1751
     *         ndarray arr
     *
     *     nlevels = len(list_of_arrays)             # <<<<<<<<<<<<<<
     *     n = len(list_of_arrays[0])
     *
     */
      if (unlikely(__pyx_v_list_of_arrays == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = PyList_GET_SIZE(__pyx_v_list_of_arrays); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_nlevels = __pyx_t_1;

     1752:     n = len(list_of_arrays[0])

      /* "pandas/algos.pyx":1752
     *
     *     nlevels = len(list_of_arrays)
     *     n = len(list_of_arrays[0])             # <<<<<<<<<<<<<<
     *
     *     cdef int64_t **vecs = <int64_t**> malloc(nlevels * sizeof(int64_t*))
     */
      if (unlikely(__pyx_v_list_of_arrays == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_2 = PyList_GET_ITEM(__pyx_v_list_of_arrays, 0);
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_n = __pyx_t_1;

     1753:

     1754:     cdef int64_t **vecs = <int64_t**> malloc(nlevels * sizeof(int64_t*))

      /* "pandas/algos.pyx":1754
     *     n = len(list_of_arrays[0])
     *
     *     cdef int64_t **vecs = <int64_t**> malloc(nlevels * sizeof(int64_t*))             # <<<<<<<<<<<<<<
     *     for i from 0 <= i < nlevels:
     *         # vecs[i] = <int64_t *> (<ndarray> list_of_arrays[i]).data
     */
      __pyx_v_vecs = ((__pyx_t_5numpy_int64_t **)malloc((__pyx_v_nlevels * (sizeof(__pyx_t_5numpy_int64_t *)))));

     1755:     for i from 0 <= i < nlevels:

      /* "pandas/algos.pyx":1755
     *
     *     cdef int64_t **vecs = <int64_t**> malloc(nlevels * sizeof(int64_t*))
     *     for i from 0 <= i < nlevels:             # <<<<<<<<<<<<<<
     *         # vecs[i] = <int64_t *> (<ndarray> list_of_arrays[i]).data
     *
     */
      __pyx_t_1 = __pyx_v_nlevels;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     1756:         # vecs[i] = <int64_t *> (<ndarray> list_of_arrays[i]).data

     1757:

     1758:         arr = list_of_arrays[i]

        /* "pandas/algos.pyx":1758
     *         # vecs[i] = <int64_t *> (<ndarray> list_of_arrays[i]).data
     *
     *         arr = list_of_arrays[i]             # <<<<<<<<<<<<<<
     *         vecs[i] = <int64_t *> arr.data
     *     # assume uniqueness??
     */
        if (unlikely(__pyx_v_list_of_arrays == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        if (!(likely(((PyList_GET_ITEM(__pyx_v_list_of_arrays, __pyx_v_i)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_list_of_arrays, __pyx_v_i), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = PyList_GET_ITEM(__pyx_v_list_of_arrays, __pyx_v_i);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XDECREF_SET(__pyx_v_arr, ((PyArrayObject *)__pyx_t_2));
        __pyx_t_2 = 0;

     1759:         vecs[i] = <int64_t *> arr.data

        /* "pandas/algos.pyx":1759
     *
     *         arr = list_of_arrays[i]
     *         vecs[i] = <int64_t *> arr.data             # <<<<<<<<<<<<<<
     *     # assume uniqueness??
     *
     */
        (__pyx_v_vecs[__pyx_v_i]) = ((__pyx_t_5numpy_int64_t *)__pyx_v_arr->data);
      }

     1760:     # assume uniqueness??

     1761:

     1762:     for i from 1 <= i < n:

      /* "pandas/algos.pyx":1762
     *     # assume uniqueness??
     *
     *     for i from 1 <= i < n:             # <<<<<<<<<<<<<<
     *         for k from 0 <= k < nlevels:
     *             cur = vecs[k][i]
     */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     1763:         for k from 0 <= k < nlevels:

        /* "pandas/algos.pyx":1763
     *
     *     for i from 1 <= i < n:
     *         for k from 0 <= k < nlevels:             # <<<<<<<<<<<<<<
     *             cur = vecs[k][i]
     *             pre = vecs[k][i-1]
     */
        __pyx_t_3 = __pyx_v_nlevels;
        for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {

     1764:             cur = vecs[k][i]

          /* "pandas/algos.pyx":1764
     *     for i from 1 <= i < n:
     *         for k from 0 <= k < nlevels:
     *             cur = vecs[k][i]             # <<<<<<<<<<<<<<
     *             pre = vecs[k][i-1]
     *             if cur == pre:
     */
          __pyx_v_cur = ((__pyx_v_vecs[__pyx_v_k])[__pyx_v_i]);

     1765:             pre = vecs[k][i-1]

          /* "pandas/algos.pyx":1765
     *         for k from 0 <= k < nlevels:
     *             cur = vecs[k][i]
     *             pre = vecs[k][i-1]             # <<<<<<<<<<<<<<
     *             if cur == pre:
     *                 continue
     */
          __pyx_v_pre = ((__pyx_v_vecs[__pyx_v_k])[(__pyx_v_i - 1)]);

     1766:             if cur == pre:

          /* "pandas/algos.pyx":1766
     *             cur = vecs[k][i]
     *             pre = vecs[k][i-1]
     *             if cur == pre:             # <<<<<<<<<<<<<<
     *                 continue
     *             elif cur > pre:
     */
          __pyx_t_4 = ((__pyx_v_cur == __pyx_v_pre) != 0);
          if (__pyx_t_4) {

     1767:                 continue

            /* "pandas/algos.pyx":1767
     *             pre = vecs[k][i-1]
     *             if cur == pre:
     *                 continue             # <<<<<<<<<<<<<<
     *             elif cur > pre:
     *                 break
     */
            goto __pyx_L7_continue;
          }

     1768:             elif cur > pre:

          /* "pandas/algos.pyx":1768
     *             if cur == pre:
     *                 continue
     *             elif cur > pre:             # <<<<<<<<<<<<<<
     *                 break
     *             else:
     */
          __pyx_t_4 = ((__pyx_v_cur > __pyx_v_pre) != 0);
          if (__pyx_t_4) {

     1769:                 break

            /* "pandas/algos.pyx":1769
     *                 continue
     *             elif cur > pre:
     *                 break             # <<<<<<<<<<<<<<
     *             else:
     *                 return False
     */
            goto __pyx_L8_break;
          }
          /*else*/ {

     1770:             else:

     1771:                 return False

            /* "pandas/algos.pyx":1771
     *                 break
     *             else:
     *                 return False             # <<<<<<<<<<<<<<
     *     free(vecs)
     *     return True
     */
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_False);
            __pyx_r = Py_False;
            goto __pyx_L0;
          }
          __pyx_L7_continue:;
        }
        __pyx_L8_break:;
      }

     1772:     free(vecs)

      /* "pandas/algos.pyx":1772
     *             else:
     *                 return False
     *     free(vecs)             # <<<<<<<<<<<<<<
     *     return True
     *
     */
      free(__pyx_v_vecs);

     1773:     return True

      /* "pandas/algos.pyx":1773
     *                 return False
     *     free(vecs)
     *     return True             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;

     1774:

     1775:

     1776: @cython.boundscheck(False)

     1777: def groupby_indices(ndarray values):

    /* "pandas/algos.pyx":1777
     *
     * @cython.boundscheck(False)
     * def groupby_indices(ndarray values):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, n = len(values)
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_59groupby_indices(PyObject *__pyx_self, PyObject *__pyx_v_values); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_59groupby_indices = {__Pyx_NAMESTR("groupby_indices"), (PyCFunction)__pyx_pw_6pandas_5algos_59groupby_indices, METH_O, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_59groupby_indices(PyObject *__pyx_self, PyObject *__pyx_v_values) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("groupby_indices (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_58groupby_indices(__pyx_self, ((PyArrayObject *)__pyx_v_values));
      CYTHON_UNUSED int __pyx_lineno = 0;
      CYTHON_UNUSED const char *__pyx_filename = NULL;
      CYTHON_UNUSED int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_58groupby_indices(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_values) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_n;
      PyArrayObject *__pyx_v_labels = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_arr = 0;
      PyArrayObject *__pyx_v_seen = 0;
      __pyx_t_5numpy_int64_t __pyx_v_loc;
      PyObject *__pyx_v_ids = 0;
      __pyx_t_5numpy_int64_t __pyx_v_k;
      __pyx_t_5numpy_int64_t **__pyx_v_vecs;
      PyObject *__pyx_v_result = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_arr;
      __Pyx_Buffer __pyx_pybuffer_arr;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_labels;
      __Pyx_Buffer __pyx_pybuffer_labels;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_seen;
      __Pyx_Buffer __pyx_pybuffer_seen;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("groupby_indices", 0);
      __pyx_pybuffer_labels.pybuffer.buf = NULL;
      __pyx_pybuffer_labels.refcount = 0;
      __pyx_pybuffernd_labels.data = NULL;
      __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_arr.pybuffer.buf = NULL;
      __pyx_pybuffer_arr.refcount = 0;
      __pyx_pybuffernd_arr.data = NULL;
      __pyx_pybuffernd_arr.rcbuffer = &__pyx_pybuffer_arr;
      __pyx_pybuffer_seen.pybuffer.buf = NULL;
      __pyx_pybuffer_seen.refcount = 0;
      __pyx_pybuffernd_seen.data = NULL;
      __pyx_pybuffernd_seen.rcbuffer = &__pyx_pybuffer_seen;

      /* "pandas/algos.pyx":1777
     *
     * @cython.boundscheck(False)
     * def groupby_indices(ndarray values):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, n = len(values)
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_seen.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.groupby_indices", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_seen.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_labels);
      __Pyx_XDECREF((PyObject *)__pyx_v_counts);
      __Pyx_XDECREF((PyObject *)__pyx_v_arr);
      __Pyx_XDECREF((PyObject *)__pyx_v_seen);
      __Pyx_XDECREF(__pyx_v_ids);
      __Pyx_XDECREF(__pyx_v_result);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1777
     *
     * @cython.boundscheck(False)
     * def groupby_indices(ndarray values):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, n = len(values)
     */
      __pyx_tuple__274 = PyTuple_Pack(13, __pyx_n_s_values, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_labels, __pyx_n_s_counts, __pyx_n_s_arr, __pyx_n_s_seen, __pyx_n_s_loc, __pyx_n_s_ids, __pyx_n_s_val, __pyx_n_s_k, __pyx_n_s_vecs, __pyx_n_s_result); if (unlikely(!__pyx_tuple__274)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__274);
      __Pyx_GIVEREF(__pyx_tuple__274);

      /* "pandas/algos.pyx":1777
     *
     * @cython.boundscheck(False)
     * def groupby_indices(ndarray values):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, n = len(values)
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_59groupby_indices, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_groupby_indices, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__275 = (PyObject*)__Pyx_PyCode_New(1, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__274, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_groupby_indices, 1777, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__275)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1778:     cdef:

     1779:         Py_ssize_t i, n = len(values)

      /* "pandas/algos.pyx":1779
     * def groupby_indices(ndarray values):
     *     cdef:
     *         Py_ssize_t i, n = len(values)             # <<<<<<<<<<<<<<
     *         ndarray[int64_t] labels, counts, arr, seen
     *         int64_t loc
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_1;

     1780:         ndarray[int64_t] labels, counts, arr, seen

     1781:         int64_t loc

     1782:         dict ids = {}

      /* "pandas/algos.pyx":1782
     *         ndarray[int64_t] labels, counts, arr, seen
     *         int64_t loc
     *         dict ids = {}             # <<<<<<<<<<<<<<
     *         object val
     *         int64_t k
     */
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_ids = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

     1783:         object val

     1784:         int64_t k

     1785:

     1786:     ids, labels, counts = group_labels(values)

      /* "pandas/algos.pyx":1786
     *         int64_t k
     *
     *     ids, labels, counts = group_labels(values)             # <<<<<<<<<<<<<<
     *     seen = np.zeros_like(counts)
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_group_labels); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_values));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_values));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_values));
      __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2);
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2);
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 2; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = NULL;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_ids, ((PyObject*)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_labels = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_counts = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1787:     seen = np.zeros_like(counts)

      /* "pandas/algos.pyx":1787
     *
     *     ids, labels, counts = group_labels(values)
     *     seen = np.zeros_like(counts)             # <<<<<<<<<<<<<<
     *
     *     # try not to get in trouble here...
     */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_counts));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_counts));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_counts));
      __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_seen.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_seen.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_seen.rcbuffer->pybuffer, (PyObject*)__pyx_v_seen, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd_seen.diminfo[0].strides = __pyx_pybuffernd_seen.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_seen.diminfo[0].shape = __pyx_pybuffernd_seen.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v_seen = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1788:

     1789:     # try not to get in trouble here...

     1790:     cdef int64_t **vecs = <int64_t **> malloc(len(ids) * sizeof(int64_t*))

      /* "pandas/algos.pyx":1790
     *
     *     # try not to get in trouble here...
     *     cdef int64_t **vecs = <int64_t **> malloc(len(ids) * sizeof(int64_t*))             # <<<<<<<<<<<<<<
     *     result = {}
     *     for i from 0 <= i < len(counts):
     */
      if (unlikely(__pyx_v_ids == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = PyDict_Size(__pyx_v_ids); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_vecs = ((__pyx_t_5numpy_int64_t **)malloc((__pyx_t_1 * (sizeof(__pyx_t_5numpy_int64_t *)))));

     1791:     result = {}

      /* "pandas/algos.pyx":1791
     *     # try not to get in trouble here...
     *     cdef int64_t **vecs = <int64_t **> malloc(len(ids) * sizeof(int64_t*))
     *     result = {}             # <<<<<<<<<<<<<<
     *     for i from 0 <= i < len(counts):
     *         arr = np.empty(counts[i], dtype=np.int64)
     */
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_result = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

     1792:     for i from 0 <= i < len(counts):

      /* "pandas/algos.pyx":1792
     *     cdef int64_t **vecs = <int64_t **> malloc(len(ids) * sizeof(int64_t*))
     *     result = {}
     *     for i from 0 <= i < len(counts):             # <<<<<<<<<<<<<<
     *         arr = np.empty(counts[i], dtype=np.int64)
     *         result[ids[i]] = arr
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_counts)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     1793:         arr = np.empty(counts[i], dtype=np.int64)

        /* "pandas/algos.pyx":1793
     *     result = {}
     *     for i from 0 <= i < len(counts):
     *         arr = np.empty(counts[i], dtype=np.int64)             # <<<<<<<<<<<<<<
     *         result[ids[i]] = arr
     *         vecs[i] = <int64_t *> arr.data
     */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_13 = __pyx_v_i;
        if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_pybuffernd_counts.diminfo[0].shape;
        __pyx_t_2 = __Pyx_PyInt_From_npy_int64((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_counts.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_8 = ((PyArrayObject *)__pyx_t_6);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
          __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_9 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_arr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
            }
          }
          __pyx_pybuffernd_arr.diminfo[0].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arr.diminfo[0].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_8 = 0;
        __Pyx_XDECREF_SET(__pyx_v_arr, ((PyArrayObject *)__pyx_t_6));
        __pyx_t_6 = 0;

     1794:         result[ids[i]] = arr

        /* "pandas/algos.pyx":1794
     *     for i from 0 <= i < len(counts):
     *         arr = np.empty(counts[i], dtype=np.int64)
     *         result[ids[i]] = arr             # <<<<<<<<<<<<<<
     *         vecs[i] = <int64_t *> arr.data
     *
     */
        if (unlikely(__pyx_v_ids == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_ids, __pyx_t_6); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(PyDict_SetItem(__pyx_v_result, __pyx_t_2, ((PyObject *)__pyx_v_arr)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     1795:         vecs[i] = <int64_t *> arr.data

        /* "pandas/algos.pyx":1795
     *         arr = np.empty(counts[i], dtype=np.int64)
     *         result[ids[i]] = arr
     *         vecs[i] = <int64_t *> arr.data             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < n:
     */
        (__pyx_v_vecs[__pyx_v_i]) = ((__pyx_t_5numpy_int64_t *)__pyx_v_arr->data);
      }

     1796:

     1797:     for i from 0 <= i < n:

      /* "pandas/algos.pyx":1797
     *         vecs[i] = <int64_t *> arr.data
     *
     *     for i from 0 <= i < n:             # <<<<<<<<<<<<<<
     *         k = labels[i]
     *
     */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     1798:         k = labels[i]

        /* "pandas/algos.pyx":1798
     *
     *     for i from 0 <= i < n:
     *         k = labels[i]             # <<<<<<<<<<<<<<
     *
     *         # was NaN
     */
        __pyx_t_14 = __pyx_v_i;
        if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_pybuffernd_labels.diminfo[0].shape;
        __pyx_v_k = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_labels.diminfo[0].strides));

     1799:

     1800:         # was NaN

     1801:         if k == -1:

        /* "pandas/algos.pyx":1801
     *
     *         # was NaN
     *         if k == -1:             # <<<<<<<<<<<<<<
     *             continue
     *
     */
        __pyx_t_15 = ((__pyx_v_k == -1) != 0);
        if (__pyx_t_15) {

     1802:             continue

          /* "pandas/algos.pyx":1802
     *         # was NaN
     *         if k == -1:
     *             continue             # <<<<<<<<<<<<<<
     *
     *         loc = seen[k]
     */
          goto __pyx_L7_continue;
        }

     1803:

     1804:         loc = seen[k]

        /* "pandas/algos.pyx":1804
     *             continue
     *
     *         loc = seen[k]             # <<<<<<<<<<<<<<
     *         vecs[k][loc] = i
     *         seen[k] = loc + 1
     */
        __pyx_t_16 = __pyx_v_k;
        if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_pybuffernd_seen.diminfo[0].shape;
        __pyx_v_loc = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_seen.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_seen.diminfo[0].strides));

     1805:         vecs[k][loc] = i

        /* "pandas/algos.pyx":1805
     *
     *         loc = seen[k]
     *         vecs[k][loc] = i             # <<<<<<<<<<<<<<
     *         seen[k] = loc + 1
     *
     */
        ((__pyx_v_vecs[__pyx_v_k])[__pyx_v_loc]) = __pyx_v_i;

     1806:         seen[k] = loc + 1

        /* "pandas/algos.pyx":1806
     *         loc = seen[k]
     *         vecs[k][loc] = i
     *         seen[k] = loc + 1             # <<<<<<<<<<<<<<
     *
     *     free(vecs)
     */
        __pyx_t_17 = __pyx_v_k;
        if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_pybuffernd_seen.diminfo[0].shape;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_seen.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_seen.diminfo[0].strides) = (__pyx_v_loc + 1);
        __pyx_L7_continue:;
      }

     1807:

     1808:     free(vecs)

      /* "pandas/algos.pyx":1808
     *         seen[k] = loc + 1
     *
     *     free(vecs)             # <<<<<<<<<<<<<<
     *
     *     return result
     */
      free(__pyx_v_vecs);

     1809:

     1810:     return result

      /* "pandas/algos.pyx":1810
     *     free(vecs)
     *
     *     return result             # <<<<<<<<<<<<<<
     *
     * @cython.wraparound(False)
     */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      goto __pyx_L0;

     1811:

     1812: @cython.wraparound(False)

     1813: @cython.boundscheck(False)

     1814: def group_labels(ndarray[object] values):

    /* "pandas/algos.pyx":1814
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def group_labels(ndarray[object] values):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute label vector from input values and associated useful data
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_61group_labels(PyObject *__pyx_self, PyObject *__pyx_v_values); /*proto*/
    static char __pyx_doc_6pandas_5algos_60group_labels[] = "\n    Compute label vector from input values and associated useful data\n\n    Returns\n    -------\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_61group_labels = {__Pyx_NAMESTR("group_labels"), (PyCFunction)__pyx_pw_6pandas_5algos_61group_labels, METH_O, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_60group_labels)};
    static PyObject *__pyx_pw_6pandas_5algos_61group_labels(PyObject *__pyx_self, PyObject *__pyx_v_values) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_labels (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_60group_labels(__pyx_self, ((PyArrayObject *)__pyx_v_values));
      CYTHON_UNUSED int __pyx_lineno = 0;
      CYTHON_UNUSED const char *__pyx_filename = NULL;
      CYTHON_UNUSED int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_60group_labels(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_values) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_n;
      PyArrayObject *__pyx_v_labels = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyObject *__pyx_v_ids = 0;
      PyObject *__pyx_v_reverse = 0;
      __pyx_t_5numpy_int64_t __pyx_v_idx;
      PyObject *__pyx_v_val = 0;
      __pyx_t_5numpy_int64_t __pyx_v_count;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_labels;
      __Pyx_Buffer __pyx_pybuffer_labels;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_labels", 0);
      __pyx_pybuffer_labels.pybuffer.buf = NULL;
      __pyx_pybuffer_labels.refcount = 0;
      __pyx_pybuffernd_labels.data = NULL;
      __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1814
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def group_labels(ndarray[object] values):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute label vector from input values and associated useful data
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.group_labels", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_labels);
      __Pyx_XDECREF((PyObject *)__pyx_v_counts);
      __Pyx_XDECREF(__pyx_v_ids);
      __Pyx_XDECREF(__pyx_v_reverse);
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1814
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def group_labels(ndarray[object] values):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute label vector from input values and associated useful data
     */
      __pyx_tuple__276 = PyTuple_Pack(10, __pyx_n_s_values, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_labels, __pyx_n_s_counts, __pyx_n_s_ids, __pyx_n_s_reverse, __pyx_n_s_idx, __pyx_n_s_val, __pyx_n_s_count); if (unlikely(!__pyx_tuple__276)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__276);
      __Pyx_GIVEREF(__pyx_tuple__276);

      /* "pandas/algos.pyx":1814
     * @cython.wraparound(False)
     * @cython.boundscheck(False)
     * def group_labels(ndarray[object] values):             # <<<<<<<<<<<<<<
     *     '''
     *     Compute label vector from input values and associated useful data
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_61group_labels, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_group_labels, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__277 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__276, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_group_labels, 1814, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__277)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1815:     '''

     1816:     Compute label vector from input values and associated useful data

     1817:

     1818:     Returns

     1819:     -------

     1820:     '''

     1821:     cdef:

     1822:         Py_ssize_t i, n = len(values)

      /* "pandas/algos.pyx":1822
     *     '''
     *     cdef:
     *         Py_ssize_t i, n = len(values)             # <<<<<<<<<<<<<<
     *         ndarray[int64_t] labels = np.empty(n, dtype=np.int64)
     *         ndarray[int64_t] counts = np.empty(n, dtype=np.int64)
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_1;

     1823:         ndarray[int64_t] labels = np.empty(n, dtype=np.int64)

      /* "pandas/algos.pyx":1823
     *     cdef:
     *         Py_ssize_t i, n = len(values)
     *         ndarray[int64_t] labels = np.empty(n, dtype=np.int64)             # <<<<<<<<<<<<<<
     *         ndarray[int64_t] counts = np.empty(n, dtype=np.int64)
     *         dict ids = {}, reverse = {}
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_labels = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_7 = 0;
      __pyx_v_labels = ((PyArrayObject *)__pyx_t_6);
      __pyx_t_6 = 0;

     1824:         ndarray[int64_t] counts = np.empty(n, dtype=np.int64)

      /* "pandas/algos.pyx":1824
     *         Py_ssize_t i, n = len(values)
     *         ndarray[int64_t] labels = np.empty(n, dtype=np.int64)
     *         ndarray[int64_t] counts = np.empty(n, dtype=np.int64)             # <<<<<<<<<<<<<<
     *         dict ids = {}, reverse = {}
     *         int64_t idx
     */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_counts = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_8 = 0;
      __pyx_v_counts = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1825:         dict ids = {}, reverse = {}

      /* "pandas/algos.pyx":1825
     *         ndarray[int64_t] labels = np.empty(n, dtype=np.int64)
     *         ndarray[int64_t] counts = np.empty(n, dtype=np.int64)
     *         dict ids = {}, reverse = {}             # <<<<<<<<<<<<<<
     *         int64_t idx
     *         object val
     */
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_ids = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_reverse = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;

     1826:         int64_t idx

     1827:         object val

     1828:         int64_t count = 0

      /* "pandas/algos.pyx":1828
     *         int64_t idx
     *         object val
     *         int64_t count = 0             # <<<<<<<<<<<<<<
     *
     *     for i from 0 <= i < n:
     */
      __pyx_v_count = 0;

     1829:

     1830:     for i from 0 <= i < n:

      /* "pandas/algos.pyx":1830
     *         int64_t count = 0
     *
     *     for i from 0 <= i < n:             # <<<<<<<<<<<<<<
     *         val = values[i]
     *
     */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

     1831:         val = values[i]

        /* "pandas/algos.pyx":1831
     *
     *     for i from 0 <= i < n:
     *         val = values[i]             # <<<<<<<<<<<<<<
     *
     *         # is NaN
     */
        __pyx_t_9 = __pyx_v_i;
        __pyx_t_5 = (PyObject *) *__Pyx_BufPtrStrided1d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_values.diminfo[0].strides);
        __Pyx_INCREF((PyObject*)__pyx_t_5);
        __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_5);
        __pyx_t_5 = 0;

     1832:

     1833:         # is NaN

     1834:         if val != val:

        /* "pandas/algos.pyx":1834
     *
     *         # is NaN
     *         if val != val:             # <<<<<<<<<<<<<<
     *             labels[i] = -1
     *             continue
     */
        __pyx_t_5 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_10) {

     1835:             labels[i] = -1

          /* "pandas/algos.pyx":1835
     *         # is NaN
     *         if val != val:
     *             labels[i] = -1             # <<<<<<<<<<<<<<
     *             continue
     *
     */
          __pyx_t_11 = __pyx_v_i;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides) = -1;

     1836:             continue

          /* "pandas/algos.pyx":1836
     *         if val != val:
     *             labels[i] = -1
     *             continue             # <<<<<<<<<<<<<<
     *
     *         # for large number of groups, not doing try: except: makes a big
     */
          goto __pyx_L3_continue;
        }

     1837:

     1838:         # for large number of groups, not doing try: except: makes a big

     1839:         # difference

     1840:         if val in ids:

        /* "pandas/algos.pyx":1840
     *         # for large number of groups, not doing try: except: makes a big
     *         # difference
     *         if val in ids:             # <<<<<<<<<<<<<<
     *             idx = ids[val]
     *             labels[i] = idx
     */
        __pyx_t_10 = (__Pyx_PyDict_Contains(__pyx_v_val, __pyx_v_ids, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = (__pyx_t_10 != 0);
        if (__pyx_t_12) {

     1841:             idx = ids[val]

          /* "pandas/algos.pyx":1841
     *         # difference
     *         if val in ids:
     *             idx = ids[val]             # <<<<<<<<<<<<<<
     *             labels[i] = idx
     *             counts[idx] = counts[idx] + 1
     */
          __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_ids, __pyx_v_val); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1841; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_13 = __Pyx_PyInt_As_npy_int64(__pyx_t_5); if (unlikely((__pyx_t_13 == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_v_idx = __pyx_t_13;

     1842:             labels[i] = idx

          /* "pandas/algos.pyx":1842
     *         if val in ids:
     *             idx = ids[val]
     *             labels[i] = idx             # <<<<<<<<<<<<<<
     *             counts[idx] = counts[idx] + 1
     *         else:
     */
          __pyx_t_14 = __pyx_v_i;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_labels.diminfo[0].strides) = __pyx_v_idx;

     1843:             counts[idx] = counts[idx] + 1

          /* "pandas/algos.pyx":1843
     *             idx = ids[val]
     *             labels[i] = idx
     *             counts[idx] = counts[idx] + 1             # <<<<<<<<<<<<<<
     *         else:
     *             ids[val] = count
     */
          __pyx_t_13 = __pyx_v_idx;
          __pyx_t_15 = __pyx_v_idx;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_counts.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_counts.diminfo[0].strides)) + 1);
          goto __pyx_L6;
        }
        /*else*/ {

     1844:         else:

     1845:             ids[val] = count

          /* "pandas/algos.pyx":1845
     *             counts[idx] = counts[idx] + 1
     *         else:
     *             ids[val] = count             # <<<<<<<<<<<<<<
     *             reverse[count] = val
     *             labels[i] = count
     */
          __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_count); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          if (unlikely(PyDict_SetItem(__pyx_v_ids, __pyx_v_val, __pyx_t_5) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     1846:             reverse[count] = val

          /* "pandas/algos.pyx":1846
     *         else:
     *             ids[val] = count
     *             reverse[count] = val             # <<<<<<<<<<<<<<
     *             labels[i] = count
     *             counts[count] = 1
     */
          __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_count); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          if (unlikely(PyDict_SetItem(__pyx_v_reverse, __pyx_t_5, __pyx_v_val) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     1847:             labels[i] = count

          /* "pandas/algos.pyx":1847
     *             ids[val] = count
     *             reverse[count] = val
     *             labels[i] = count             # <<<<<<<<<<<<<<
     *             counts[count] = 1
     *             count += 1
     */
          __pyx_t_16 = __pyx_v_i;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_labels.diminfo[0].strides) = __pyx_v_count;

     1848:             counts[count] = 1

          /* "pandas/algos.pyx":1848
     *             reverse[count] = val
     *             labels[i] = count
     *             counts[count] = 1             # <<<<<<<<<<<<<<
     *             count += 1
     *
     */
          __pyx_t_17 = __pyx_v_count;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_counts.diminfo[0].strides) = 1;

     1849:             count += 1

          /* "pandas/algos.pyx":1849
     *             labels[i] = count
     *             counts[count] = 1
     *             count += 1             # <<<<<<<<<<<<<<
     *
     *     return reverse, labels, counts[:count].copy()
     */
          __pyx_v_count = (__pyx_v_count + 1);
        }
        __pyx_L6:;
        __pyx_L3_continue:;
      }

     1850:

     1851:     return reverse, labels, counts[:count].copy()

      /* "pandas/algos.pyx":1851
     *             count += 1
     *
     *     return reverse, labels, counts[:count].copy()             # <<<<<<<<<<<<<<
     *
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_counts), 0, __pyx_v_count, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_reverse);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reverse);
      __Pyx_GIVEREF(__pyx_v_reverse);
      __Pyx_INCREF(((PyObject *)__pyx_v_labels));
      PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_labels));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_labels));
      PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L0;

     1852:

     1853:

     1854: @cython.boundscheck(False)

     1855: @cython.wraparound(False)

     1856: def groupsort_indexer(ndarray[int64_t] index, Py_ssize_t ngroups):

    /* "pandas/algos.pyx":1856
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def groupsort_indexer(ndarray[int64_t] index, Py_ssize_t ngroups):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, loc, label, n
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_63groupsort_indexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_6pandas_5algos_63groupsort_indexer = {__Pyx_NAMESTR("groupsort_indexer"), (PyCFunction)__pyx_pw_6pandas_5algos_63groupsort_indexer, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
    static PyObject *__pyx_pw_6pandas_5algos_63groupsort_indexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_index = 0;
      Py_ssize_t __pyx_v_ngroups;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("groupsort_indexer (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_index,&__pyx_n_s_ngroups,0};
        PyObject* values[2] = {0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ngroups)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("groupsort_indexer", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "groupsort_indexer") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        }
        __pyx_v_index = ((PyArrayObject *)values[0]);
        __pyx_v_ngroups = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_ngroups == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("groupsort_indexer", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.groupsort_indexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_62groupsort_indexer(__pyx_self, __pyx_v_index, __pyx_v_ngroups);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_62groupsort_indexer(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_index, Py_ssize_t __pyx_v_ngroups) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_label;
      Py_ssize_t __pyx_v_n;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_where = 0;
      PyArrayObject *__pyx_v_result = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_index;
      __Pyx_Buffer __pyx_pybuffer_index;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_where;
      __Pyx_Buffer __pyx_pybuffer_where;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("groupsort_indexer", 0);
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_where.pybuffer.buf = NULL;
      __pyx_pybuffer_where.refcount = 0;
      __pyx_pybuffernd_where.data = NULL;
      __pyx_pybuffernd_where.rcbuffer = &__pyx_pybuffer_where;
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_index.pybuffer.buf = NULL;
      __pyx_pybuffer_index.refcount = 0;
      __pyx_pybuffernd_index.data = NULL;
      __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1856
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def groupsort_indexer(ndarray[int64_t] index, Py_ssize_t ngroups):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, loc, label, n
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_where.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.groupsort_indexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_where.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_counts);
      __Pyx_XDECREF((PyObject *)__pyx_v_where);
      __Pyx_XDECREF((PyObject *)__pyx_v_result);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1856
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def groupsort_indexer(ndarray[int64_t] index, Py_ssize_t ngroups):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, loc, label, n
     */
      __pyx_tuple__278 = PyTuple_Pack(9, __pyx_n_s_index, __pyx_n_s_ngroups, __pyx_n_s_i, __pyx_n_s_loc, __pyx_n_s_label, __pyx_n_s_n, __pyx_n_s_counts, __pyx_n_s_where, __pyx_n_s_result); if (unlikely(!__pyx_tuple__278)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__278);
      __Pyx_GIVEREF(__pyx_tuple__278);

      /* "pandas/algos.pyx":1856
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def groupsort_indexer(ndarray[int64_t] index, Py_ssize_t ngroups):             # <<<<<<<<<<<<<<
     *     cdef:
     *         Py_ssize_t i, loc, label, n
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_63groupsort_indexer, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_groupsort_indexer, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__279 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__278, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_groupsort_indexer, 1856, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__279)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1857:     cdef:

     1858:         Py_ssize_t i, loc, label, n

     1859:         ndarray[int64_t] counts, where, result

     1860:

     1861:     # count group sizes, location 0 for NA

     1862:     counts = np.zeros(ngroups + 1, dtype=np.int64)

      /* "pandas/algos.pyx":1862
     *
     *     # count group sizes, location 0 for NA
     *     counts = np.zeros(ngroups + 1, dtype=np.int64)             # <<<<<<<<<<<<<<
     *     n = len(index)
     *     for i from 0 <= i < n:
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ngroups + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_counts = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1863:     n = len(index)

      /* "pandas/algos.pyx":1863
     *     # count group sizes, location 0 for NA
     *     counts = np.zeros(ngroups + 1, dtype=np.int64)
     *     n = len(index)             # <<<<<<<<<<<<<<
     *     for i from 0 <= i < n:
     *         counts[index[i] + 1] += 1
     */
      __pyx_t_11 = PyObject_Length(((PyObject *)__pyx_v_index)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_n = __pyx_t_11;

     1864:     for i from 0 <= i < n:

      /* "pandas/algos.pyx":1864
     *     counts = np.zeros(ngroups + 1, dtype=np.int64)
     *     n = len(index)
     *     for i from 0 <= i < n:             # <<<<<<<<<<<<<<
     *         counts[index[i] + 1] += 1
     *
     */
      __pyx_t_11 = __pyx_v_n;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_11; __pyx_v_i++) {

     1865:         counts[index[i] + 1] += 1

        /* "pandas/algos.pyx":1865
     *     n = len(index)
     *     for i from 0 <= i < n:
     *         counts[index[i] + 1] += 1             # <<<<<<<<<<<<<<
     *
     *     # mark the start of each contiguous group of like-indexed data
     */
        __pyx_t_12 = __pyx_v_i;
        __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_index.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_index.diminfo[0].strides)) + 1);
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_counts.diminfo[0].strides) += 1;
      }

     1866:

     1867:     # mark the start of each contiguous group of like-indexed data

     1868:     where = np.zeros(ngroups + 1, dtype=np.int64)

      /* "pandas/algos.pyx":1868
     *
     *     # mark the start of each contiguous group of like-indexed data
     *     where = np.zeros(ngroups + 1, dtype=np.int64)             # <<<<<<<<<<<<<<
     *     for i from 1 <= i < ngroups + 1:
     *         where[i] = where[i - 1] + counts[i - 1]
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_ngroups + 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_where.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_where.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_where.rcbuffer->pybuffer, (PyObject*)__pyx_v_where, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_where.diminfo[0].strides = __pyx_pybuffernd_where.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_where.diminfo[0].shape = __pyx_pybuffernd_where.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_where = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

     1869:     for i from 1 <= i < ngroups + 1:

      /* "pandas/algos.pyx":1869
     *     # mark the start of each contiguous group of like-indexed data
     *     where = np.zeros(ngroups + 1, dtype=np.int64)
     *     for i from 1 <= i < ngroups + 1:             # <<<<<<<<<<<<<<
     *         where[i] = where[i - 1] + counts[i - 1]
     *
     */
      __pyx_t_11 = (__pyx_v_ngroups + 1);
      for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_11; __pyx_v_i++) {

     1870:         where[i] = where[i - 1] + counts[i - 1]

        /* "pandas/algos.pyx":1870
     *     where = np.zeros(ngroups + 1, dtype=np.int64)
     *     for i from 1 <= i < ngroups + 1:
     *         where[i] = where[i - 1] + counts[i - 1]             # <<<<<<<<<<<<<<
     *
     *     # this is our indexer
     */
        __pyx_t_14 = (__pyx_v_i - 1);
        __pyx_t_15 = (__pyx_v_i - 1);
        __pyx_t_16 = __pyx_v_i;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_where.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_where.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_where.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_where.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_counts.diminfo[0].strides)));
      }

     1871:

     1872:     # this is our indexer

     1873:     result = np.zeros(n, dtype=np.int64)

      /* "pandas/algos.pyx":1873
     *
     *     # this is our indexer
     *     result = np.zeros(n, dtype=np.int64)             # <<<<<<<<<<<<<<
     *     for i from 0 <= i < n:
     *         label = index[i] + 1
     */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_result = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1874:     for i from 0 <= i < n:

      /* "pandas/algos.pyx":1874
     *     # this is our indexer
     *     result = np.zeros(n, dtype=np.int64)
     *     for i from 0 <= i < n:             # <<<<<<<<<<<<<<
     *         label = index[i] + 1
     *         result[where[label]] = i
     */
      __pyx_t_11 = __pyx_v_n;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_11; __pyx_v_i++) {

     1875:         label = index[i] + 1

        /* "pandas/algos.pyx":1875
     *     result = np.zeros(n, dtype=np.int64)
     *     for i from 0 <= i < n:
     *         label = index[i] + 1             # <<<<<<<<<<<<<<
     *         result[where[label]] = i
     *         where[label] += 1
     */
        __pyx_t_17 = __pyx_v_i;
        __pyx_v_label = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_index.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_index.diminfo[0].strides)) + 1);

     1876:         result[where[label]] = i

        /* "pandas/algos.pyx":1876
     *     for i from 0 <= i < n:
     *         label = index[i] + 1
     *         result[where[label]] = i             # <<<<<<<<<<<<<<
     *         where[label] += 1
     *
     */
        __pyx_t_18 = __pyx_v_label;
        __pyx_t_19 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_where.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_where.diminfo[0].strides));
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_i;

     1877:         where[label] += 1

        /* "pandas/algos.pyx":1877
     *         label = index[i] + 1
     *         result[where[label]] = i
     *         where[label] += 1             # <<<<<<<<<<<<<<
     *
     *     return result, counts
     */
        __pyx_t_20 = __pyx_v_label;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_where.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_where.diminfo[0].strides) += 1;
      }

     1878:

     1879:     return result, counts

      /* "pandas/algos.pyx":1879
     *         where[label] += 1
     *
     *     return result, counts             # <<<<<<<<<<<<<<
     *
     * # TODO: aggregate multiple columns in single pass
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_result));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_result));
      __Pyx_INCREF(((PyObject *)__pyx_v_counts));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_counts));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_counts));
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

     1880:

     1881: # TODO: aggregate multiple columns in single pass

     1882: #----------------------------------------------------------------------

     1883: # first, nth, last

     1884:

     1885: @cython.boundscheck(False)

     1886: @cython.wraparound(False)

     1887: def group_nth_object(ndarray[object, ndim=2] out,

    /* "pandas/algos.pyx":1887
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                      ndarray[int64_t] counts,
     *                      ndarray[object, ndim=2] values,
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_65group_nth_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_64group_nth_object[] = "\n    Only aggregates on axis=0\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_65group_nth_object = {__Pyx_NAMESTR("group_nth_object"), (PyCFunction)__pyx_pw_6pandas_5algos_65group_nth_object, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_64group_nth_object)};
    static PyObject *__pyx_pw_6pandas_5algos_65group_nth_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_out = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_labels = 0;
      __pyx_t_5numpy_int64_t __pyx_v_rank;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_nth_object (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_out,&__pyx_n_s_counts,&__pyx_n_s_values,&__pyx_n_s_labels,&__pyx_n_s_rank,0};
        PyObject* values[5] = {0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_counts)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_object", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_object", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_labels)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_object", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  4:
            if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rank)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_object", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "group_nth_object") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        }
        __pyx_v_out = ((PyArrayObject *)values[0]);
        __pyx_v_counts = ((PyArrayObject *)values[1]);
        __pyx_v_values = ((PyArrayObject *)values[2]);
        __pyx_v_labels = ((PyArrayObject *)values[3]);
        __pyx_v_rank = __Pyx_PyInt_As_npy_int64(values[4]); if (unlikely((__pyx_v_rank == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("group_nth_object", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.group_nth_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_counts), __pyx_ptype_5numpy_ndarray, 1, "counts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_64group_nth_object(__pyx_self, __pyx_v_out, __pyx_v_counts, __pyx_v_values, __pyx_v_labels, __pyx_v_rank);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_64group_nth_object(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_out, PyArrayObject *__pyx_v_counts, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_labels, __pyx_t_5numpy_int64_t __pyx_v_rank) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      Py_ssize_t __pyx_v_lab;
      PyObject *__pyx_v_val = 0;
      PyArrayObject *__pyx_v_nobs = 0;
      PyArrayObject *__pyx_v_resx = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_labels;
      __Pyx_Buffer __pyx_pybuffer_labels;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_nobs;
      __Pyx_Buffer __pyx_pybuffer_nobs;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
      __Pyx_Buffer __pyx_pybuffer_out;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_resx;
      __Pyx_Buffer __pyx_pybuffer_resx;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_nth_object", 0);
      __pyx_pybuffer_nobs.pybuffer.buf = NULL;
      __pyx_pybuffer_nobs.refcount = 0;
      __pyx_pybuffernd_nobs.data = NULL;
      __pyx_pybuffernd_nobs.rcbuffer = &__pyx_pybuffer_nobs;
      __pyx_pybuffer_resx.pybuffer.buf = NULL;
      __pyx_pybuffer_resx.refcount = 0;
      __pyx_pybuffernd_resx.data = NULL;
      __pyx_pybuffernd_resx.rcbuffer = &__pyx_pybuffer_resx;
      __pyx_pybuffer_out.pybuffer.buf = NULL;
      __pyx_pybuffer_out.refcount = 0;
      __pyx_pybuffernd_out.data = NULL;
      __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_labels.pybuffer.buf = NULL;
      __pyx_pybuffer_labels.refcount = 0;
      __pyx_pybuffernd_labels.data = NULL;
      __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1887
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                      ndarray[int64_t] counts,
     *                      ndarray[object, ndim=2] values,
     */

      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.group_nth_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XDECREF((PyObject *)__pyx_v_nobs);
      __Pyx_XDECREF((PyObject *)__pyx_v_resx);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1887
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                      ndarray[int64_t] counts,
     *                      ndarray[object, ndim=2] values,
     */
      __pyx_tuple__280 = PyTuple_Pack(14, __pyx_n_s_out, __pyx_n_s_counts, __pyx_n_s_values, __pyx_n_s_labels, __pyx_n_s_rank, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_lab, __pyx_n_s_val, __pyx_n_s_count, __pyx_n_s_nobs, __pyx_n_s_resx); if (unlikely(!__pyx_tuple__280)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__280);
      __Pyx_GIVEREF(__pyx_tuple__280);

      /* "pandas/algos.pyx":1887
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                      ndarray[int64_t] counts,
     *                      ndarray[object, ndim=2] values,
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_65group_nth_object, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_group_nth_object, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__281 = (PyObject*)__Pyx_PyCode_New(5, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__280, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_group_nth_object, 1887, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__281)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1888:                      ndarray[int64_t] counts,

     1889:                      ndarray[object, ndim=2] values,

     1890:                      ndarray[int64_t] labels,

     1891:                      int64_t rank):

     1892:     '''

     1893:     Only aggregates on axis=0

     1894:     '''

     1895:     cdef:

     1896:         Py_ssize_t i, j, N, K, lab

     1897:         object val

     1898:         float64_t count

     1899:         ndarray[int64_t, ndim=2] nobs

     1900:         ndarray[object, ndim=2] resx

     1901:

     1902:     nobs = np.zeros((<object> out).shape, dtype=np.int64)

      /* "pandas/algos.pyx":1902
     *         ndarray[object, ndim=2] resx
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.int64)             # <<<<<<<<<<<<<<
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_v_nobs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_nobs.diminfo[0].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nobs.diminfo[0].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nobs.diminfo[1].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nobs.diminfo[1].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_nobs = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1903:     resx = np.empty((<object> out).shape, dtype=object)

      /* "pandas/algos.pyx":1903
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.int64)
     *     resx = np.empty((<object> out).shape, dtype=object)             # <<<<<<<<<<<<<<
     *
     *     N, K = (<object> values).shape
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_builtin_object) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_v_resx, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_resx.diminfo[0].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_resx.diminfo[0].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_resx.diminfo[1].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_resx.diminfo[1].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = 0;
      __pyx_v_resx = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1904:

     1905:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":1905
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *
     *     for i in range(N):
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_1)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_3 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_13;
      __pyx_v_K = __pyx_t_14;

     1906:

     1907:     for i in range(N):

      /* "pandas/algos.pyx":1907
     *     N, K = (<object> values).shape
     *
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         lab = labels[i]
     *         if lab < 0:
     */
      __pyx_t_14 = __pyx_v_N;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_14; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

     1908:         lab = labels[i]

        /* "pandas/algos.pyx":1908
     *
     *     for i in range(N):
     *         lab = labels[i]             # <<<<<<<<<<<<<<
     *         if lab < 0:
     *             continue
     */
        __pyx_t_15 = __pyx_v_i;
        __pyx_v_lab = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_labels.diminfo[0].strides));

     1909:         if lab < 0:

        /* "pandas/algos.pyx":1909
     *     for i in range(N):
     *         lab = labels[i]
     *         if lab < 0:             # <<<<<<<<<<<<<<
     *             continue
     *
     */
        __pyx_t_16 = ((__pyx_v_lab < 0) != 0);
        if (__pyx_t_16) {

     1910:             continue

          /* "pandas/algos.pyx":1910
     *         lab = labels[i]
     *         if lab < 0:
     *             continue             # <<<<<<<<<<<<<<
     *
     *         counts[lab] += 1
     */
          goto __pyx_L5_continue;
        }

     1911:

     1912:         counts[lab] += 1

        /* "pandas/algos.pyx":1912
     *             continue
     *
     *         counts[lab] += 1             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             val = values[i, j]
     */
        __pyx_t_17 = __pyx_v_lab;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_counts.diminfo[0].strides) += 1;

     1913:         for j in range(K):

        /* "pandas/algos.pyx":1913
     *
     *         counts[lab] += 1
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *
     */
        __pyx_t_18 = __pyx_v_K;
        for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
          __pyx_v_j = __pyx_t_19;

     1914:             val = values[i, j]

          /* "pandas/algos.pyx":1914
     *         counts[lab] += 1
     *         for j in range(K):
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *
     *             # not nan
     */
          __pyx_t_20 = __pyx_v_i;
          __pyx_t_21 = __pyx_v_j;
          __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_values.diminfo[1].strides);
          __Pyx_INCREF((PyObject*)__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_2);
          __pyx_t_2 = 0;

     1915:

     1916:             # not nan

     1917:             if val == val:

          /* "pandas/algos.pyx":1917
     *
     *             # not nan
     *             if val == val:             # <<<<<<<<<<<<<<
     *                 nobs[lab, j] += 1
     *                 if nobs[lab, j] == rank:
     */
          __pyx_t_2 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_16) {

     1918:                 nobs[lab, j] += 1

            /* "pandas/algos.pyx":1918
     *             # not nan
     *             if val == val:
     *                 nobs[lab, j] += 1             # <<<<<<<<<<<<<<
     *                 if nobs[lab, j] == rank:
     *                     resx[lab, j] = val
     */
            __pyx_t_22 = __pyx_v_lab;
            __pyx_t_23 = __pyx_v_j;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_nobs.diminfo[1].strides) += 1;

     1919:                 if nobs[lab, j] == rank:

            /* "pandas/algos.pyx":1919
     *             if val == val:
     *                 nobs[lab, j] += 1
     *                 if nobs[lab, j] == rank:             # <<<<<<<<<<<<<<
     *                     resx[lab, j] = val
     *
     */
            __pyx_t_24 = __pyx_v_lab;
            __pyx_t_25 = __pyx_v_j;
            __pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_nobs.diminfo[1].strides)) == __pyx_v_rank) != 0);
            if (__pyx_t_16) {

     1920:                     resx[lab, j] = val

              /* "pandas/algos.pyx":1920
     *                 nobs[lab, j] += 1
     *                 if nobs[lab, j] == rank:
     *                     resx[lab, j] = val             # <<<<<<<<<<<<<<
     *
     *     for i in range(len(counts)):
     */
              __pyx_t_26 = __pyx_v_lab;
              __pyx_t_27 = __pyx_v_j;
              __pyx_t_28 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_resx.diminfo[1].strides);
              __Pyx_GOTREF(*__pyx_t_28);
              __Pyx_INCREF(__pyx_v_val); __Pyx_DECREF(*__pyx_t_28);
              *__pyx_t_28 = __pyx_v_val;
              __Pyx_GIVEREF(*__pyx_t_28);
              goto __pyx_L11;
            }
            __pyx_L11:;
            goto __pyx_L10;
          }
          __pyx_L10:;
        }
        __pyx_L5_continue:;
      }

     1921:

     1922:     for i in range(len(counts)):

      /* "pandas/algos.pyx":1922
     *                     resx[lab, j] = val
     *
     *     for i in range(len(counts)):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     */
      __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_counts)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_14; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

     1923:         for j in range(K):

        /* "pandas/algos.pyx":1923
     *
     *     for i in range(len(counts)):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             if nobs[i, j] == 0:
     *                 out[i, j] = <object> nan
     */
        __pyx_t_18 = __pyx_v_K;
        for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
          __pyx_v_j = __pyx_t_19;

     1924:             if nobs[i, j] == 0:

          /* "pandas/algos.pyx":1924
     *     for i in range(len(counts)):
     *         for j in range(K):
     *             if nobs[i, j] == 0:             # <<<<<<<<<<<<<<
     *                 out[i, j] = <object> nan
     *             else:
     */
          __pyx_t_29 = __pyx_v_i;
          __pyx_t_30 = __pyx_v_j;
          __pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_nobs.diminfo[1].strides)) == 0) != 0);
          if (__pyx_t_16) {

     1925:                 out[i, j] = <object> nan

            /* "pandas/algos.pyx":1925
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     *                 out[i, j] = <object> nan             # <<<<<<<<<<<<<<
     *             else:
     *                 out[i, j] = resx[i, j]
     */
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_6pandas_5algos_nan); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_t_2;
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_31 = __pyx_v_i;
            __pyx_t_32 = __pyx_v_j;
            __pyx_t_28 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_28);
            __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(*__pyx_t_28);
            *__pyx_t_28 = __pyx_t_3;
            __Pyx_GIVEREF(*__pyx_t_28);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            goto __pyx_L16;
          }
          /*else*/ {

     1926:             else:

     1927:                 out[i, j] = resx[i, j]

            /* "pandas/algos.pyx":1927
     *                 out[i, j] = <object> nan
     *             else:
     *                 out[i, j] = resx[i, j]             # <<<<<<<<<<<<<<
     *
     * @cython.boundscheck(False)
     */
            __pyx_t_33 = __pyx_v_i;
            __pyx_t_34 = __pyx_v_j;
            __pyx_t_3 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_resx.diminfo[1].strides);
            __Pyx_INCREF((PyObject*)__pyx_t_3);
            __pyx_t_35 = __pyx_v_i;
            __pyx_t_36 = __pyx_v_j;
            __pyx_t_28 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_28);
            __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(*__pyx_t_28);
            *__pyx_t_28 = __pyx_t_3;
            __Pyx_GIVEREF(*__pyx_t_28);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          }
          __pyx_L16:;
        }
      }

     1928:

     1929: @cython.boundscheck(False)

     1930: @cython.wraparound(False)

     1931: def group_nth_bin_object(ndarray[object, ndim=2] out,

    /* "pandas/algos.pyx":1931
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                          ndarray[int64_t] counts,
     *                          ndarray[object, ndim=2] values,
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_67group_nth_bin_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_66group_nth_bin_object[] = "\n    Only aggregates on axis=0\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_67group_nth_bin_object = {__Pyx_NAMESTR("group_nth_bin_object"), (PyCFunction)__pyx_pw_6pandas_5algos_67group_nth_bin_object, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_66group_nth_bin_object)};
    static PyObject *__pyx_pw_6pandas_5algos_67group_nth_bin_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_out = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_bins = 0;
      __pyx_t_5numpy_int64_t __pyx_v_rank;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_nth_bin_object (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_out,&__pyx_n_s_counts,&__pyx_n_s_values,&__pyx_n_s_bins,&__pyx_n_s_rank,0};
        PyObject* values[5] = {0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_counts)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_bin_object", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_bin_object", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bins)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_bin_object", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  4:
            if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rank)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_nth_bin_object", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "group_nth_bin_object") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        }
        __pyx_v_out = ((PyArrayObject *)values[0]);
        __pyx_v_counts = ((PyArrayObject *)values[1]);
        __pyx_v_values = ((PyArrayObject *)values[2]);
        __pyx_v_bins = ((PyArrayObject *)values[3]);
        __pyx_v_rank = __Pyx_PyInt_As_npy_int64(values[4]); if (unlikely((__pyx_v_rank == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("group_nth_bin_object", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.group_nth_bin_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_counts), __pyx_ptype_5numpy_ndarray, 1, "counts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bins), __pyx_ptype_5numpy_ndarray, 1, "bins", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_66group_nth_bin_object(__pyx_self, __pyx_v_out, __pyx_v_counts, __pyx_v_values, __pyx_v_bins, __pyx_v_rank);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_66group_nth_bin_object(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_out, PyArrayObject *__pyx_v_counts, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_bins, __pyx_t_5numpy_int64_t __pyx_v_rank) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      Py_ssize_t __pyx_v_ngroups;
      Py_ssize_t __pyx_v_b;
      PyObject *__pyx_v_val = 0;
      PyArrayObject *__pyx_v_resx = 0;
      PyArrayObject *__pyx_v_nobs = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_bins;
      __Pyx_Buffer __pyx_pybuffer_bins;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_nobs;
      __Pyx_Buffer __pyx_pybuffer_nobs;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
      __Pyx_Buffer __pyx_pybuffer_out;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_resx;
      __Pyx_Buffer __pyx_pybuffer_resx;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_nth_bin_object", 0);
      __pyx_pybuffer_resx.pybuffer.buf = NULL;
      __pyx_pybuffer_resx.refcount = 0;
      __pyx_pybuffernd_resx.data = NULL;
      __pyx_pybuffernd_resx.rcbuffer = &__pyx_pybuffer_resx;
      __pyx_pybuffer_nobs.pybuffer.buf = NULL;
      __pyx_pybuffer_nobs.refcount = 0;
      __pyx_pybuffernd_nobs.data = NULL;
      __pyx_pybuffernd_nobs.rcbuffer = &__pyx_pybuffer_nobs;
      __pyx_pybuffer_out.pybuffer.buf = NULL;
      __pyx_pybuffer_out.refcount = 0;
      __pyx_pybuffernd_out.data = NULL;
      __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_bins.pybuffer.buf = NULL;
      __pyx_pybuffer_bins.refcount = 0;
      __pyx_pybuffernd_bins.data = NULL;
      __pyx_pybuffernd_bins.rcbuffer = &__pyx_pybuffer_bins;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bins.rcbuffer->pybuffer, (PyObject*)__pyx_v_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_bins.diminfo[0].strides = __pyx_pybuffernd_bins.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bins.diminfo[0].shape = __pyx_pybuffernd_bins.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1931
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                          ndarray[int64_t] counts,
     *                          ndarray[object, ndim=2] values,
     */

      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bins.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.group_nth_bin_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bins.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XDECREF((PyObject *)__pyx_v_resx);
      __Pyx_XDECREF((PyObject *)__pyx_v_nobs);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1931
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                          ndarray[int64_t] counts,
     *                          ndarray[object, ndim=2] values,
     */
      __pyx_tuple__282 = PyTuple_Pack(15, __pyx_n_s_out, __pyx_n_s_counts, __pyx_n_s_values, __pyx_n_s_bins, __pyx_n_s_rank, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_ngroups, __pyx_n_s_b, __pyx_n_s_val, __pyx_n_s_count, __pyx_n_s_resx, __pyx_n_s_nobs); if (unlikely(!__pyx_tuple__282)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__282);
      __Pyx_GIVEREF(__pyx_tuple__282);

      /* "pandas/algos.pyx":1931
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_nth_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                          ndarray[int64_t] counts,
     *                          ndarray[object, ndim=2] values,
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_67group_nth_bin_object, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_group_nth_bin_object, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__283 = (PyObject*)__Pyx_PyCode_New(5, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__282, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_group_nth_bin_object, 1931, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__283)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1932:                          ndarray[int64_t] counts,

     1933:                          ndarray[object, ndim=2] values,

     1934:                          ndarray[int64_t] bins, int64_t rank):

     1935:     '''

     1936:     Only aggregates on axis=0

     1937:     '''

     1938:     cdef:

     1939:         Py_ssize_t i, j, N, K, ngroups, b

     1940:         object val

     1941:         float64_t count

     1942:         ndarray[object, ndim=2] resx

     1943:         ndarray[float64_t, ndim=2] nobs

     1944:

     1945:     nobs = np.zeros((<object> out).shape, dtype=np.float64)

      /* "pandas/algos.pyx":1945
     *         ndarray[float64_t, ndim=2] nobs
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.float64)             # <<<<<<<<<<<<<<
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_v_nobs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_nobs.diminfo[0].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nobs.diminfo[0].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nobs.diminfo[1].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nobs.diminfo[1].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_nobs = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1946:     resx = np.empty((<object> out).shape, dtype=object)

      /* "pandas/algos.pyx":1946
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.float64)
     *     resx = np.empty((<object> out).shape, dtype=object)             # <<<<<<<<<<<<<<
     *
     *     if bins[len(bins) - 1] == len(values):
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_builtin_object) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_v_resx, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_resx.diminfo[0].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_resx.diminfo[0].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_resx.diminfo[1].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_resx.diminfo[1].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = 0;
      __pyx_v_resx = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1947:

     1948:     if bins[len(bins) - 1] == len(values):

      /* "pandas/algos.pyx":1948
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     *     if bins[len(bins) - 1] == len(values):             # <<<<<<<<<<<<<<
     *         ngroups = len(bins)
     *     else:
     */
      __pyx_t_12 = PyObject_Length(((PyObject *)__pyx_v_bins)); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = (__pyx_t_12 - 1);
      __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_15 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_bins.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_bins.diminfo[0].strides)) == __pyx_t_14) != 0);
      if (__pyx_t_15) {

     1949:         ngroups = len(bins)

        /* "pandas/algos.pyx":1949
     *
     *     if bins[len(bins) - 1] == len(values):
     *         ngroups = len(bins)             # <<<<<<<<<<<<<<
     *     else:
     *         ngroups = len(bins) + 1
     */
        __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_bins)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_ngroups = __pyx_t_14;
        goto __pyx_L3;
      }
      /*else*/ {

     1950:     else:

     1951:         ngroups = len(bins) + 1

        /* "pandas/algos.pyx":1951
     *         ngroups = len(bins)
     *     else:
     *         ngroups = len(bins) + 1             # <<<<<<<<<<<<<<
     *
     *     N, K = (<object> values).shape
     */
        __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_bins)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_ngroups = (__pyx_t_14 + 1);
      }
      __pyx_L3:;

     1952:

     1953:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":1953
     *         ngroups = len(bins) + 1
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *
     *     b = 0
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_16 = Py_TYPE(__pyx_t_1)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_16(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_3 = __pyx_t_16(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_16 = NULL;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L5_unpacking_done;
        __pyx_L4_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_16 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L5_unpacking_done:;
      }
      __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_14;
      __pyx_v_K = __pyx_t_12;

     1954:

     1955:     b = 0

      /* "pandas/algos.pyx":1955
     *     N, K = (<object> values).shape
     *
     *     b = 0             # <<<<<<<<<<<<<<
     *     for i in range(N):
     *         while b < ngroups - 1 and i >= bins[b]:
     */
      __pyx_v_b = 0;

     1956:     for i in range(N):

      /* "pandas/algos.pyx":1956
     *
     *     b = 0
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         while b < ngroups - 1 and i >= bins[b]:
     *             b += 1
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_12; __pyx_t_14+=1) {
        __pyx_v_i = __pyx_t_14;

     1957:         while b < ngroups - 1 and i >= bins[b]:

        /* "pandas/algos.pyx":1957
     *     b = 0
     *     for i in range(N):
     *         while b < ngroups - 1 and i >= bins[b]:             # <<<<<<<<<<<<<<
     *             b += 1
     *
     */
        while (1) {
          __pyx_t_15 = ((__pyx_v_b < (__pyx_v_ngroups - 1)) != 0);
          if (__pyx_t_15) {
            __pyx_t_17 = __pyx_v_b;
            __pyx_t_18 = ((__pyx_v_i >= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_bins.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_bins.diminfo[0].strides))) != 0);
            __pyx_t_19 = __pyx_t_18;
          } else {
            __pyx_t_19 = __pyx_t_15;
          }
          if (!__pyx_t_19) break;

     1958:             b += 1

          /* "pandas/algos.pyx":1958
     *     for i in range(N):
     *         while b < ngroups - 1 and i >= bins[b]:
     *             b += 1             # <<<<<<<<<<<<<<
     *
     *         counts[b] += 1
     */
          __pyx_v_b = (__pyx_v_b + 1);
        }

     1959:

     1960:         counts[b] += 1

        /* "pandas/algos.pyx":1960
     *             b += 1
     *
     *         counts[b] += 1             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             val = values[i, j]
     */
        __pyx_t_20 = __pyx_v_b;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_counts.diminfo[0].strides) += 1;

     1961:         for j in range(K):

        /* "pandas/algos.pyx":1961
     *
     *         counts[b] += 1
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *
     */
        __pyx_t_21 = __pyx_v_K;
        for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
          __pyx_v_j = __pyx_t_22;

     1962:             val = values[i, j]

          /* "pandas/algos.pyx":1962
     *         counts[b] += 1
     *         for j in range(K):
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *
     *             # not nan
     */
          __pyx_t_23 = __pyx_v_i;
          __pyx_t_24 = __pyx_v_j;
          __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_values.diminfo[1].strides);
          __Pyx_INCREF((PyObject*)__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_2);
          __pyx_t_2 = 0;

     1963:

     1964:             # not nan

     1965:             if val == val:

          /* "pandas/algos.pyx":1965
     *
     *             # not nan
     *             if val == val:             # <<<<<<<<<<<<<<
     *                 nobs[b, j] += 1
     *                 if nobs[b, j] == rank:
     */
          __pyx_t_2 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_19) {

     1966:                 nobs[b, j] += 1

            /* "pandas/algos.pyx":1966
     *             # not nan
     *             if val == val:
     *                 nobs[b, j] += 1             # <<<<<<<<<<<<<<
     *                 if nobs[b, j] == rank:
     *                     resx[b, j] = val
     */
            __pyx_t_25 = __pyx_v_b;
            __pyx_t_26 = __pyx_v_j;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_nobs.diminfo[1].strides) += 1.0;

     1967:                 if nobs[b, j] == rank:

            /* "pandas/algos.pyx":1967
     *             if val == val:
     *                 nobs[b, j] += 1
     *                 if nobs[b, j] == rank:             # <<<<<<<<<<<<<<
     *                     resx[b, j] = val
     *
     */
            __pyx_t_27 = __pyx_v_b;
            __pyx_t_28 = __pyx_v_j;
            __pyx_t_19 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_nobs.diminfo[1].strides)) == __pyx_v_rank) != 0);
            if (__pyx_t_19) {

     1968:                     resx[b, j] = val

              /* "pandas/algos.pyx":1968
     *                 nobs[b, j] += 1
     *                 if nobs[b, j] == rank:
     *                     resx[b, j] = val             # <<<<<<<<<<<<<<
     *
     *     for i in range(ngroups):
     */
              __pyx_t_29 = __pyx_v_b;
              __pyx_t_30 = __pyx_v_j;
              __pyx_t_31 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_resx.diminfo[1].strides);
              __Pyx_GOTREF(*__pyx_t_31);
              __Pyx_INCREF(__pyx_v_val); __Pyx_DECREF(*__pyx_t_31);
              *__pyx_t_31 = __pyx_v_val;
              __Pyx_GIVEREF(*__pyx_t_31);
              goto __pyx_L13;
            }
            __pyx_L13:;
            goto __pyx_L12;
          }
          __pyx_L12:;
        }
      }

     1969:

     1970:     for i in range(ngroups):

      /* "pandas/algos.pyx":1970
     *                     resx[b, j] = val
     *
     *     for i in range(ngroups):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     */
      __pyx_t_12 = __pyx_v_ngroups;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_12; __pyx_t_14+=1) {
        __pyx_v_i = __pyx_t_14;

     1971:         for j in range(K):

        /* "pandas/algos.pyx":1971
     *
     *     for i in range(ngroups):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             if nobs[i, j] == 0:
     *                 out[i, j] = nan
     */
        __pyx_t_21 = __pyx_v_K;
        for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
          __pyx_v_j = __pyx_t_22;

     1972:             if nobs[i, j] == 0:

          /* "pandas/algos.pyx":1972
     *     for i in range(ngroups):
     *         for j in range(K):
     *             if nobs[i, j] == 0:             # <<<<<<<<<<<<<<
     *                 out[i, j] = nan
     *             else:
     */
          __pyx_t_32 = __pyx_v_i;
          __pyx_t_33 = __pyx_v_j;
          __pyx_t_19 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_nobs.diminfo[1].strides)) == 0.0) != 0);
          if (__pyx_t_19) {

     1973:                 out[i, j] = nan

            /* "pandas/algos.pyx":1973
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     *                 out[i, j] = nan             # <<<<<<<<<<<<<<
     *             else:
     *                 out[i, j] = resx[i, j]
     */
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_6pandas_5algos_nan); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_34 = __pyx_v_i;
            __pyx_t_35 = __pyx_v_j;
            __pyx_t_31 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_31);
            __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(*__pyx_t_31);
            *__pyx_t_31 = __pyx_t_2;
            __Pyx_GIVEREF(*__pyx_t_31);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            goto __pyx_L18;
          }
          /*else*/ {

     1974:             else:

     1975:                 out[i, j] = resx[i, j]

            /* "pandas/algos.pyx":1975
     *                 out[i, j] = nan
     *             else:
     *                 out[i, j] = resx[i, j]             # <<<<<<<<<<<<<<
     *
     * @cython.boundscheck(False)
     */
            __pyx_t_36 = __pyx_v_i;
            __pyx_t_37 = __pyx_v_j;
            __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_resx.diminfo[1].strides);
            __Pyx_INCREF((PyObject*)__pyx_t_2);
            __pyx_t_38 = __pyx_v_i;
            __pyx_t_39 = __pyx_v_j;
            __pyx_t_31 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_31);
            __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(*__pyx_t_31);
            *__pyx_t_31 = __pyx_t_2;
            __Pyx_GIVEREF(*__pyx_t_31);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __pyx_L18:;
        }
      }

     1976:

     1977: @cython.boundscheck(False)

     1978: @cython.wraparound(False)

     1979: def group_last_object(ndarray[object, ndim=2] out,

    /* "pandas/algos.pyx":1979
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                       ndarray[int64_t] counts,
     *                       ndarray[object, ndim=2] values,
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_69group_last_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_68group_last_object[] = "\n    Only aggregates on axis=0\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_69group_last_object = {__Pyx_NAMESTR("group_last_object"), (PyCFunction)__pyx_pw_6pandas_5algos_69group_last_object, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_68group_last_object)};
    static PyObject *__pyx_pw_6pandas_5algos_69group_last_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_out = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_labels = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_last_object (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_out,&__pyx_n_s_counts,&__pyx_n_s_values,&__pyx_n_s_labels,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_counts)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_last_object", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_last_object", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_labels)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_last_object", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "group_last_object") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        }
        __pyx_v_out = ((PyArrayObject *)values[0]);
        __pyx_v_counts = ((PyArrayObject *)values[1]);
        __pyx_v_values = ((PyArrayObject *)values[2]);
        __pyx_v_labels = ((PyArrayObject *)values[3]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("group_last_object", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.group_last_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_counts), __pyx_ptype_5numpy_ndarray, 1, "counts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_68group_last_object(__pyx_self, __pyx_v_out, __pyx_v_counts, __pyx_v_values, __pyx_v_labels);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_68group_last_object(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_out, PyArrayObject *__pyx_v_counts, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_labels) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      Py_ssize_t __pyx_v_lab;
      PyObject *__pyx_v_val = 0;
      PyArrayObject *__pyx_v_resx = 0;
      PyArrayObject *__pyx_v_nobs = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_labels;
      __Pyx_Buffer __pyx_pybuffer_labels;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_nobs;
      __Pyx_Buffer __pyx_pybuffer_nobs;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
      __Pyx_Buffer __pyx_pybuffer_out;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_resx;
      __Pyx_Buffer __pyx_pybuffer_resx;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_last_object", 0);
      __pyx_pybuffer_resx.pybuffer.buf = NULL;
      __pyx_pybuffer_resx.refcount = 0;
      __pyx_pybuffernd_resx.data = NULL;
      __pyx_pybuffernd_resx.rcbuffer = &__pyx_pybuffer_resx;
      __pyx_pybuffer_nobs.pybuffer.buf = NULL;
      __pyx_pybuffer_nobs.refcount = 0;
      __pyx_pybuffernd_nobs.data = NULL;
      __pyx_pybuffernd_nobs.rcbuffer = &__pyx_pybuffer_nobs;
      __pyx_pybuffer_out.pybuffer.buf = NULL;
      __pyx_pybuffer_out.refcount = 0;
      __pyx_pybuffernd_out.data = NULL;
      __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_labels.pybuffer.buf = NULL;
      __pyx_pybuffer_labels.refcount = 0;
      __pyx_pybuffernd_labels.data = NULL;
      __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":1979
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                       ndarray[int64_t] counts,
     *                       ndarray[object, ndim=2] values,
     */

      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.group_last_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XDECREF((PyObject *)__pyx_v_resx);
      __Pyx_XDECREF((PyObject *)__pyx_v_nobs);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":1979
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                       ndarray[int64_t] counts,
     *                       ndarray[object, ndim=2] values,
     */
      __pyx_tuple__284 = PyTuple_Pack(13, __pyx_n_s_out, __pyx_n_s_counts, __pyx_n_s_values, __pyx_n_s_labels, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_lab, __pyx_n_s_val, __pyx_n_s_count, __pyx_n_s_resx, __pyx_n_s_nobs); if (unlikely(!__pyx_tuple__284)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__284);
      __Pyx_GIVEREF(__pyx_tuple__284);

      /* "pandas/algos.pyx":1979
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                       ndarray[int64_t] counts,
     *                       ndarray[object, ndim=2] values,
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_69group_last_object, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_group_last_object, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__285 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__284, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_group_last_object, 1979, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__285)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     1980:                       ndarray[int64_t] counts,

     1981:                       ndarray[object, ndim=2] values,

     1982:                       ndarray[int64_t] labels):

     1983:     '''

     1984:     Only aggregates on axis=0

     1985:     '''

     1986:     cdef:

     1987:         Py_ssize_t i, j, N, K, lab

     1988:         object val

     1989:         float64_t count

     1990:         ndarray[object, ndim=2] resx

     1991:         ndarray[int64_t, ndim=2] nobs

     1992:

     1993:     nobs = np.zeros((<object> out).shape, dtype=np.int64)

      /* "pandas/algos.pyx":1993
     *         ndarray[int64_t, ndim=2] nobs
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.int64)             # <<<<<<<<<<<<<<
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_v_nobs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_nobs.diminfo[0].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nobs.diminfo[0].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nobs.diminfo[1].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nobs.diminfo[1].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_nobs = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     1994:     resx = np.empty((<object> out).shape, dtype=object)

      /* "pandas/algos.pyx":1994
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.int64)
     *     resx = np.empty((<object> out).shape, dtype=object)             # <<<<<<<<<<<<<<
     *
     *     N, K = (<object> values).shape
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_builtin_object) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_v_resx, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_resx.diminfo[0].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_resx.diminfo[0].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_resx.diminfo[1].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_resx.diminfo[1].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = 0;
      __pyx_v_resx = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     1995:

     1996:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":1996
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *
     *     for i in range(N):
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_1)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_3 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_13;
      __pyx_v_K = __pyx_t_14;

     1997:

     1998:     for i in range(N):

      /* "pandas/algos.pyx":1998
     *     N, K = (<object> values).shape
     *
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         lab = labels[i]
     *         if lab < 0:
     */
      __pyx_t_14 = __pyx_v_N;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_14; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

     1999:         lab = labels[i]

        /* "pandas/algos.pyx":1999
     *
     *     for i in range(N):
     *         lab = labels[i]             # <<<<<<<<<<<<<<
     *         if lab < 0:
     *             continue
     */
        __pyx_t_15 = __pyx_v_i;
        __pyx_v_lab = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_labels.diminfo[0].strides));

     2000:         if lab < 0:

        /* "pandas/algos.pyx":2000
     *     for i in range(N):
     *         lab = labels[i]
     *         if lab < 0:             # <<<<<<<<<<<<<<
     *             continue
     *
     */
        __pyx_t_16 = ((__pyx_v_lab < 0) != 0);
        if (__pyx_t_16) {

     2001:             continue

          /* "pandas/algos.pyx":2001
     *         lab = labels[i]
     *         if lab < 0:
     *             continue             # <<<<<<<<<<<<<<
     *
     *         counts[lab] += 1
     */
          goto __pyx_L5_continue;
        }

     2002:

     2003:         counts[lab] += 1

        /* "pandas/algos.pyx":2003
     *             continue
     *
     *         counts[lab] += 1             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             val = values[i, j]
     */
        __pyx_t_17 = __pyx_v_lab;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_counts.diminfo[0].strides) += 1;

     2004:         for j in range(K):

        /* "pandas/algos.pyx":2004
     *
     *         counts[lab] += 1
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *
     */
        __pyx_t_18 = __pyx_v_K;
        for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
          __pyx_v_j = __pyx_t_19;

     2005:             val = values[i, j]

          /* "pandas/algos.pyx":2005
     *         counts[lab] += 1
     *         for j in range(K):
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *
     *             # not nan
     */
          __pyx_t_20 = __pyx_v_i;
          __pyx_t_21 = __pyx_v_j;
          __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_values.diminfo[1].strides);
          __Pyx_INCREF((PyObject*)__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_2);
          __pyx_t_2 = 0;

     2006:

     2007:             # not nan

     2008:             if val == val:

          /* "pandas/algos.pyx":2008
     *
     *             # not nan
     *             if val == val:             # <<<<<<<<<<<<<<
     *                 nobs[lab, j] += 1
     *                 resx[lab, j] = val
     */
          __pyx_t_2 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_16) {

     2009:                 nobs[lab, j] += 1

            /* "pandas/algos.pyx":2009
     *             # not nan
     *             if val == val:
     *                 nobs[lab, j] += 1             # <<<<<<<<<<<<<<
     *                 resx[lab, j] = val
     *
     */
            __pyx_t_22 = __pyx_v_lab;
            __pyx_t_23 = __pyx_v_j;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_nobs.diminfo[1].strides) += 1;

     2010:                 resx[lab, j] = val

            /* "pandas/algos.pyx":2010
     *             if val == val:
     *                 nobs[lab, j] += 1
     *                 resx[lab, j] = val             # <<<<<<<<<<<<<<
     *
     *     for i in range(len(counts)):
     */
            __pyx_t_24 = __pyx_v_lab;
            __pyx_t_25 = __pyx_v_j;
            __pyx_t_26 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_resx.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_26);
            __Pyx_INCREF(__pyx_v_val); __Pyx_DECREF(*__pyx_t_26);
            *__pyx_t_26 = __pyx_v_val;
            __Pyx_GIVEREF(*__pyx_t_26);
            goto __pyx_L10;
          }
          __pyx_L10:;
        }
        __pyx_L5_continue:;
      }

     2011:

     2012:     for i in range(len(counts)):

      /* "pandas/algos.pyx":2012
     *                 resx[lab, j] = val
     *
     *     for i in range(len(counts)):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     */
      __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_counts)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_14; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

     2013:         for j in range(K):

        /* "pandas/algos.pyx":2013
     *
     *     for i in range(len(counts)):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             if nobs[i, j] == 0:
     *                 out[i, j] = nan
     */
        __pyx_t_18 = __pyx_v_K;
        for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
          __pyx_v_j = __pyx_t_19;

     2014:             if nobs[i, j] == 0:

          /* "pandas/algos.pyx":2014
     *     for i in range(len(counts)):
     *         for j in range(K):
     *             if nobs[i, j] == 0:             # <<<<<<<<<<<<<<
     *                 out[i, j] = nan
     *             else:
     */
          __pyx_t_27 = __pyx_v_i;
          __pyx_t_28 = __pyx_v_j;
          __pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_nobs.diminfo[1].strides)) == 0) != 0);
          if (__pyx_t_16) {

     2015:                 out[i, j] = nan

            /* "pandas/algos.pyx":2015
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     *                 out[i, j] = nan             # <<<<<<<<<<<<<<
     *             else:
     *                 out[i, j] = resx[i, j]
     */
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_6pandas_5algos_nan); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_29 = __pyx_v_i;
            __pyx_t_30 = __pyx_v_j;
            __pyx_t_26 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_26);
            __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(*__pyx_t_26);
            *__pyx_t_26 = __pyx_t_2;
            __Pyx_GIVEREF(*__pyx_t_26);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            goto __pyx_L15;
          }
          /*else*/ {

     2016:             else:

     2017:                 out[i, j] = resx[i, j]

            /* "pandas/algos.pyx":2017
     *                 out[i, j] = nan
     *             else:
     *                 out[i, j] = resx[i, j]             # <<<<<<<<<<<<<<
     *
     * @cython.boundscheck(False)
     */
            __pyx_t_31 = __pyx_v_i;
            __pyx_t_32 = __pyx_v_j;
            __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_resx.diminfo[1].strides);
            __Pyx_INCREF((PyObject*)__pyx_t_2);
            __pyx_t_33 = __pyx_v_i;
            __pyx_t_34 = __pyx_v_j;
            __pyx_t_26 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_26);
            __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(*__pyx_t_26);
            *__pyx_t_26 = __pyx_t_2;
            __Pyx_GIVEREF(*__pyx_t_26);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __pyx_L15:;
        }
      }

     2018:

     2019: @cython.boundscheck(False)

     2020: @cython.wraparound(False)

     2021: def group_last_bin_object(ndarray[object, ndim=2] out,

    /* "pandas/algos.pyx":2021
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                           ndarray[int64_t] counts,
     *                           ndarray[object, ndim=2] values,
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_71group_last_bin_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_70group_last_bin_object[] = "\n    Only aggregates on axis=0\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_71group_last_bin_object = {__Pyx_NAMESTR("group_last_bin_object"), (PyCFunction)__pyx_pw_6pandas_5algos_71group_last_bin_object, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_70group_last_bin_object)};
    static PyObject *__pyx_pw_6pandas_5algos_71group_last_bin_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_out = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_bins = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_last_bin_object (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_out,&__pyx_n_s_counts,&__pyx_n_s_values,&__pyx_n_s_bins,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_counts)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_last_bin_object", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_last_bin_object", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bins)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_last_bin_object", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "group_last_bin_object") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        }
        __pyx_v_out = ((PyArrayObject *)values[0]);
        __pyx_v_counts = ((PyArrayObject *)values[1]);
        __pyx_v_values = ((PyArrayObject *)values[2]);
        __pyx_v_bins = ((PyArrayObject *)values[3]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("group_last_bin_object", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.group_last_bin_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_counts), __pyx_ptype_5numpy_ndarray, 1, "counts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bins), __pyx_ptype_5numpy_ndarray, 1, "bins", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_70group_last_bin_object(__pyx_self, __pyx_v_out, __pyx_v_counts, __pyx_v_values, __pyx_v_bins);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_70group_last_bin_object(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_out, PyArrayObject *__pyx_v_counts, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_bins) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      Py_ssize_t __pyx_v_ngroups;
      Py_ssize_t __pyx_v_b;
      PyObject *__pyx_v_val = 0;
      PyArrayObject *__pyx_v_resx = 0;
      PyArrayObject *__pyx_v_nobs = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_bins;
      __Pyx_Buffer __pyx_pybuffer_bins;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_nobs;
      __Pyx_Buffer __pyx_pybuffer_nobs;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
      __Pyx_Buffer __pyx_pybuffer_out;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_resx;
      __Pyx_Buffer __pyx_pybuffer_resx;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_last_bin_object", 0);
      __pyx_pybuffer_resx.pybuffer.buf = NULL;
      __pyx_pybuffer_resx.refcount = 0;
      __pyx_pybuffernd_resx.data = NULL;
      __pyx_pybuffernd_resx.rcbuffer = &__pyx_pybuffer_resx;
      __pyx_pybuffer_nobs.pybuffer.buf = NULL;
      __pyx_pybuffer_nobs.refcount = 0;
      __pyx_pybuffernd_nobs.data = NULL;
      __pyx_pybuffernd_nobs.rcbuffer = &__pyx_pybuffer_nobs;
      __pyx_pybuffer_out.pybuffer.buf = NULL;
      __pyx_pybuffer_out.refcount = 0;
      __pyx_pybuffernd_out.data = NULL;
      __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_bins.pybuffer.buf = NULL;
      __pyx_pybuffer_bins.refcount = 0;
      __pyx_pybuffernd_bins.data = NULL;
      __pyx_pybuffernd_bins.rcbuffer = &__pyx_pybuffer_bins;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bins.rcbuffer->pybuffer, (PyObject*)__pyx_v_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_bins.diminfo[0].strides = __pyx_pybuffernd_bins.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bins.diminfo[0].shape = __pyx_pybuffernd_bins.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":2021
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                           ndarray[int64_t] counts,
     *                           ndarray[object, ndim=2] values,
     */

      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bins.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.group_last_bin_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bins.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF(__pyx_v_val);
      __Pyx_XDECREF((PyObject *)__pyx_v_resx);
      __Pyx_XDECREF((PyObject *)__pyx_v_nobs);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":2021
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                           ndarray[int64_t] counts,
     *                           ndarray[object, ndim=2] values,
     */
      __pyx_tuple__286 = PyTuple_Pack(14, __pyx_n_s_out, __pyx_n_s_counts, __pyx_n_s_values, __pyx_n_s_bins, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_ngroups, __pyx_n_s_b, __pyx_n_s_val, __pyx_n_s_count, __pyx_n_s_resx, __pyx_n_s_nobs); if (unlikely(!__pyx_tuple__286)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__286);
      __Pyx_GIVEREF(__pyx_tuple__286);

      /* "pandas/algos.pyx":2021
     * @cython.boundscheck(False)
     * @cython.wraparound(False)
     * def group_last_bin_object(ndarray[object, ndim=2] out,             # <<<<<<<<<<<<<<
     *                           ndarray[int64_t] counts,
     *                           ndarray[object, ndim=2] values,
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_71group_last_bin_object, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_group_last_bin_object, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__287 = (PyObject*)__Pyx_PyCode_New(4, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__286, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_group_last_bin_object, 2021, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__287)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     2022:                           ndarray[int64_t] counts,

     2023:                           ndarray[object, ndim=2] values,

     2024:                           ndarray[int64_t] bins):

     2025:     '''

     2026:     Only aggregates on axis=0

     2027:     '''

     2028:     cdef:

     2029:         Py_ssize_t i, j, N, K, ngroups, b

     2030:         object val

     2031:         float64_t count

     2032:         ndarray[object, ndim=2] resx

     2033:         ndarray[float64_t, ndim=2] nobs

     2034:

     2035:     nobs = np.zeros((<object> out).shape, dtype=np.float64)

      /* "pandas/algos.pyx":2035
     *         ndarray[float64_t, ndim=2] nobs
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.float64)             # <<<<<<<<<<<<<<
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nobs.rcbuffer->pybuffer, (PyObject*)__pyx_v_nobs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
        }
        __pyx_pybuffernd_nobs.diminfo[0].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nobs.diminfo[0].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nobs.diminfo[1].strides = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nobs.diminfo[1].shape = __pyx_pybuffernd_nobs.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __pyx_v_nobs = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

     2036:     resx = np.empty((<object> out).shape, dtype=object)

      /* "pandas/algos.pyx":2036
     *
     *     nobs = np.zeros((<object> out).shape, dtype=np.float64)
     *     resx = np.empty((<object> out).shape, dtype=object)             # <<<<<<<<<<<<<<
     *
     *     if bins[len(bins) - 1] == len(values):
     */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_builtin_object) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_resx.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_resx.rcbuffer->pybuffer, (PyObject*)__pyx_v_resx, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
          }
        }
        __pyx_pybuffernd_resx.diminfo[0].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_resx.diminfo[0].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_resx.diminfo[1].strides = __pyx_pybuffernd_resx.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_resx.diminfo[1].shape = __pyx_pybuffernd_resx.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = 0;
      __pyx_v_resx = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     2037:

     2038:     if bins[len(bins) - 1] == len(values):

      /* "pandas/algos.pyx":2038
     *     resx = np.empty((<object> out).shape, dtype=object)
     *
     *     if bins[len(bins) - 1] == len(values):             # <<<<<<<<<<<<<<
     *         ngroups = len(bins)
     *     else:
     */
      __pyx_t_12 = PyObject_Length(((PyObject *)__pyx_v_bins)); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = (__pyx_t_12 - 1);
      __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_15 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_bins.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_bins.diminfo[0].strides)) == __pyx_t_14) != 0);
      if (__pyx_t_15) {

     2039:         ngroups = len(bins)

        /* "pandas/algos.pyx":2039
     *
     *     if bins[len(bins) - 1] == len(values):
     *         ngroups = len(bins)             # <<<<<<<<<<<<<<
     *     else:
     *         ngroups = len(bins) + 1
     */
        __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_bins)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_ngroups = __pyx_t_14;
        goto __pyx_L3;
      }
      /*else*/ {

     2040:     else:

     2041:         ngroups = len(bins) + 1

        /* "pandas/algos.pyx":2041
     *         ngroups = len(bins)
     *     else:
     *         ngroups = len(bins) + 1             # <<<<<<<<<<<<<<
     *
     *     N, K = (<object> values).shape
     */
        __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_bins)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_ngroups = (__pyx_t_14 + 1);
      }
      __pyx_L3:;

     2042:

     2043:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":2043
     *         ngroups = len(bins) + 1
     *
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *
     *     b = 0
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_16 = Py_TYPE(__pyx_t_1)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_16(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_3 = __pyx_t_16(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_16 = NULL;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L5_unpacking_done;
        __pyx_L4_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_16 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L5_unpacking_done:;
      }
      __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_N = __pyx_t_14;
      __pyx_v_K = __pyx_t_12;

     2044:

     2045:     b = 0

      /* "pandas/algos.pyx":2045
     *     N, K = (<object> values).shape
     *
     *     b = 0             # <<<<<<<<<<<<<<
     *     for i in range(N):
     *         while b < ngroups - 1 and i >= bins[b]:
     */
      __pyx_v_b = 0;

     2046:     for i in range(N):

      /* "pandas/algos.pyx":2046
     *
     *     b = 0
     *     for i in range(N):             # <<<<<<<<<<<<<<
     *         while b < ngroups - 1 and i >= bins[b]:
     *             b += 1
     */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_12; __pyx_t_14+=1) {
        __pyx_v_i = __pyx_t_14;

     2047:         while b < ngroups - 1 and i >= bins[b]:

        /* "pandas/algos.pyx":2047
     *     b = 0
     *     for i in range(N):
     *         while b < ngroups - 1 and i >= bins[b]:             # <<<<<<<<<<<<<<
     *             b += 1
     *
     */
        while (1) {
          __pyx_t_15 = ((__pyx_v_b < (__pyx_v_ngroups - 1)) != 0);
          if (__pyx_t_15) {
            __pyx_t_17 = __pyx_v_b;
            __pyx_t_18 = ((__pyx_v_i >= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_bins.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_bins.diminfo[0].strides))) != 0);
            __pyx_t_19 = __pyx_t_18;
          } else {
            __pyx_t_19 = __pyx_t_15;
          }
          if (!__pyx_t_19) break;

     2048:             b += 1

          /* "pandas/algos.pyx":2048
     *     for i in range(N):
     *         while b < ngroups - 1 and i >= bins[b]:
     *             b += 1             # <<<<<<<<<<<<<<
     *
     *         counts[b] += 1
     */
          __pyx_v_b = (__pyx_v_b + 1);
        }

     2049:

     2050:         counts[b] += 1

        /* "pandas/algos.pyx":2050
     *             b += 1
     *
     *         counts[b] += 1             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             val = values[i, j]
     */
        __pyx_t_20 = __pyx_v_b;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_counts.diminfo[0].strides) += 1;

     2051:         for j in range(K):

        /* "pandas/algos.pyx":2051
     *
     *         counts[b] += 1
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             val = values[i, j]
     *
     */
        __pyx_t_21 = __pyx_v_K;
        for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
          __pyx_v_j = __pyx_t_22;

     2052:             val = values[i, j]

          /* "pandas/algos.pyx":2052
     *         counts[b] += 1
     *         for j in range(K):
     *             val = values[i, j]             # <<<<<<<<<<<<<<
     *
     *             # not nan
     */
          __pyx_t_23 = __pyx_v_i;
          __pyx_t_24 = __pyx_v_j;
          __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_values.diminfo[1].strides);
          __Pyx_INCREF((PyObject*)__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_2);
          __pyx_t_2 = 0;

     2053:

     2054:             # not nan

     2055:             if val == val:

          /* "pandas/algos.pyx":2055
     *
     *             # not nan
     *             if val == val:             # <<<<<<<<<<<<<<
     *                 nobs[b, j] += 1
     *                 resx[b, j] = val
     */
          __pyx_t_2 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_19) {

     2056:                 nobs[b, j] += 1

            /* "pandas/algos.pyx":2056
     *             # not nan
     *             if val == val:
     *                 nobs[b, j] += 1             # <<<<<<<<<<<<<<
     *                 resx[b, j] = val
     *
     */
            __pyx_t_25 = __pyx_v_b;
            __pyx_t_26 = __pyx_v_j;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_nobs.diminfo[1].strides) += 1.0;

     2057:                 resx[b, j] = val

            /* "pandas/algos.pyx":2057
     *             if val == val:
     *                 nobs[b, j] += 1
     *                 resx[b, j] = val             # <<<<<<<<<<<<<<
     *
     *     for i in range(ngroups):
     */
            __pyx_t_27 = __pyx_v_b;
            __pyx_t_28 = __pyx_v_j;
            __pyx_t_29 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_resx.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_29);
            __Pyx_INCREF(__pyx_v_val); __Pyx_DECREF(*__pyx_t_29);
            *__pyx_t_29 = __pyx_v_val;
            __Pyx_GIVEREF(*__pyx_t_29);
            goto __pyx_L12;
          }
          __pyx_L12:;
        }
      }

     2058:

     2059:     for i in range(ngroups):

      /* "pandas/algos.pyx":2059
     *                 resx[b, j] = val
     *
     *     for i in range(ngroups):             # <<<<<<<<<<<<<<
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     */
      __pyx_t_12 = __pyx_v_ngroups;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_12; __pyx_t_14+=1) {
        __pyx_v_i = __pyx_t_14;

     2060:         for j in range(K):

        /* "pandas/algos.pyx":2060
     *
     *     for i in range(ngroups):
     *         for j in range(K):             # <<<<<<<<<<<<<<
     *             if nobs[i, j] == 0:
     *                 out[i, j] = nan
     */
        __pyx_t_21 = __pyx_v_K;
        for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
          __pyx_v_j = __pyx_t_22;

     2061:             if nobs[i, j] == 0:

          /* "pandas/algos.pyx":2061
     *     for i in range(ngroups):
     *         for j in range(K):
     *             if nobs[i, j] == 0:             # <<<<<<<<<<<<<<
     *                 out[i, j] = nan
     *             else:
     */
          __pyx_t_30 = __pyx_v_i;
          __pyx_t_31 = __pyx_v_j;
          __pyx_t_19 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_nobs.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_nobs.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_nobs.diminfo[1].strides)) == 0.0) != 0);
          if (__pyx_t_19) {

     2062:                 out[i, j] = nan

            /* "pandas/algos.pyx":2062
     *         for j in range(K):
     *             if nobs[i, j] == 0:
     *                 out[i, j] = nan             # <<<<<<<<<<<<<<
     *             else:
     *                 out[i, j] = resx[i, j]
     */
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_6pandas_5algos_nan); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_32 = __pyx_v_i;
            __pyx_t_33 = __pyx_v_j;
            __pyx_t_29 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_29);
            __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(*__pyx_t_29);
            *__pyx_t_29 = __pyx_t_2;
            __Pyx_GIVEREF(*__pyx_t_29);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            goto __pyx_L17;
          }
          /*else*/ {

     2063:             else:

     2064:                 out[i, j] = resx[i, j]

            /* "pandas/algos.pyx":2064
     *                 out[i, j] = nan
     *             else:
     *                 out[i, j] = resx[i, j]             # <<<<<<<<<<<<<<
     *
     *
     */
            __pyx_t_34 = __pyx_v_i;
            __pyx_t_35 = __pyx_v_j;
            __pyx_t_2 = (PyObject *) *__Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_resx.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_resx.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_resx.diminfo[1].strides);
            __Pyx_INCREF((PyObject*)__pyx_t_2);
            __pyx_t_36 = __pyx_v_i;
            __pyx_t_37 = __pyx_v_j;
            __pyx_t_29 = __Pyx_BufPtrStrided2d(PyObject **, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_out.diminfo[1].strides);
            __Pyx_GOTREF(*__pyx_t_29);
            __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(*__pyx_t_29);
            *__pyx_t_29 = __pyx_t_2;
            __Pyx_GIVEREF(*__pyx_t_29);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __pyx_L17:;
        }
      }

     2065:

     2066:

     2067:

     2068: #----------------------------------------------------------------------

     2069: # median

     2070:

     2071: def group_median(ndarray[float64_t, ndim=2] out,

    /* "pandas/algos.pyx":2071
     * # median
     *
     * def group_median(ndarray[float64_t, ndim=2] out,             # <<<<<<<<<<<<<<
     *                  ndarray[int64_t] counts,
     *                  ndarray[float64_t, ndim=2] values,
     */

    /* Python wrapper */
    static PyObject *__pyx_pw_6pandas_5algos_73group_median(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static char __pyx_doc_6pandas_5algos_72group_median[] = "\n    Only aggregates on axis=0\n    ";
    static PyMethodDef __pyx_mdef_6pandas_5algos_73group_median = {__Pyx_NAMESTR("group_median"), (PyCFunction)__pyx_pw_6pandas_5algos_73group_median, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6pandas_5algos_72group_median)};
    static PyObject *__pyx_pw_6pandas_5algos_73group_median(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_out = 0;
      PyArrayObject *__pyx_v_counts = 0;
      PyArrayObject *__pyx_v_values = 0;
      PyArrayObject *__pyx_v_labels = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_median (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_out,&__pyx_n_s_counts,&__pyx_n_s_values,&__pyx_n_s_labels,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            case  1:
            if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_counts)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_median", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  2:
            if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_median", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            case  3:
            if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_labels)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("group_median", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "group_median") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        }
        __pyx_v_out = ((PyArrayObject *)values[0]);
        __pyx_v_counts = ((PyArrayObject *)values[1]);
        __pyx_v_values = ((PyArrayObject *)values[2]);
        __pyx_v_labels = ((PyArrayObject *)values[3]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("group_median", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("pandas.algos.group_median", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_counts), __pyx_ptype_5numpy_ndarray, 1, "counts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_pf_6pandas_5algos_72group_median(__pyx_self, __pyx_v_out, __pyx_v_counts, __pyx_v_values, __pyx_v_labels);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6pandas_5algos_72group_median(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_out, PyArrayObject *__pyx_v_counts, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_labels) {
      Py_ssize_t __pyx_v_i;
      Py_ssize_t __pyx_v_j;
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_K;
      Py_ssize_t __pyx_v_ngroups;
      Py_ssize_t __pyx_v_size;
      PyArrayObject *__pyx_v__counts = 0;
      PyArrayObject *__pyx_v_data = 0;
      __pyx_t_5numpy_float64_t *__pyx_v_ptr;
      PyObject *__pyx_v_indexer = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd__counts;
      __Pyx_Buffer __pyx_pybuffer__counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
      __Pyx_Buffer __pyx_pybuffer_counts;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_labels;
      __Pyx_Buffer __pyx_pybuffer_labels;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
      __Pyx_Buffer __pyx_pybuffer_out;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
      __Pyx_Buffer __pyx_pybuffer_values;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("group_median", 0);
      __pyx_pybuffer__counts.pybuffer.buf = NULL;
      __pyx_pybuffer__counts.refcount = 0;
      __pyx_pybuffernd__counts.data = NULL;
      __pyx_pybuffernd__counts.rcbuffer = &__pyx_pybuffer__counts;
      __pyx_pybuffer_out.pybuffer.buf = NULL;
      __pyx_pybuffer_out.refcount = 0;
      __pyx_pybuffernd_out.data = NULL;
      __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
      __pyx_pybuffer_counts.pybuffer.buf = NULL;
      __pyx_pybuffer_counts.refcount = 0;
      __pyx_pybuffernd_counts.data = NULL;
      __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
      __pyx_pybuffer_values.pybuffer.buf = NULL;
      __pyx_pybuffer_values.refcount = 0;
      __pyx_pybuffernd_values.data = NULL;
      __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
      __pyx_pybuffer_labels.pybuffer.buf = NULL;
      __pyx_pybuffer_labels.refcount = 0;
      __pyx_pybuffernd_labels.data = NULL;
      __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_v_counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0];

      /* "pandas/algos.pyx":2071
     * # median
     *
     * def group_median(ndarray[float64_t, ndim=2] out,             # <<<<<<<<<<<<<<
     *                  ndarray[int64_t] counts,
     *                  ndarray[float64_t, ndim=2] values,
     */

      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_13);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pandas.algos.group_median", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_labels.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v__counts);
      __Pyx_XDECREF((PyObject *)__pyx_v_data);
      __Pyx_XDECREF(__pyx_v_indexer);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

      /* "pandas/algos.pyx":2071
     * # median
     *
     * def group_median(ndarray[float64_t, ndim=2] out,             # <<<<<<<<<<<<<<
     *                  ndarray[int64_t] counts,
     *                  ndarray[float64_t, ndim=2] values,
     */
      __pyx_tuple__288 = PyTuple_Pack(14, __pyx_n_s_out, __pyx_n_s_counts, __pyx_n_s_values, __pyx_n_s_labels, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_ngroups, __pyx_n_s_size, __pyx_n_s_counts_2, __pyx_n_s_data, __pyx_n_s_ptr, __pyx_n_s_indexer); if (unlikely(!__pyx_tuple__288)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_tuple__288);
      __Pyx_GIVEREF(__pyx_tuple__288);

      /* "pandas/algos.pyx":2071
     * # median
     *
     * def group_median(ndarray[float64_t, ndim=2] out,             # <<<<<<<<<<<<<<
     *                  ndarray[int64_t] counts,
     *                  ndarray[float64_t, ndim=2] values,
     */
      __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6pandas_5algos_73group_median, NULL, __pyx_n_s_pandas_algos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_group_median, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_codeobj__289 = (PyObject*)__Pyx_PyCode_New(4, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__288, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mnt_home_jreback_pandas_pandas, __pyx_n_s_group_median, 2071, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__289)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     2072:                  ndarray[int64_t] counts,

     2073:                  ndarray[float64_t, ndim=2] values,

     2074:                  ndarray[int64_t] labels):

     2075:     '''

     2076:     Only aggregates on axis=0

     2077:     '''

     2078:     cdef:

     2079:         Py_ssize_t i, j, N, K, ngroups, size

     2080:         ndarray[int64_t] _counts

     2081:         ndarray data

     2082:         float64_t* ptr

     2083:     ngroups = len(counts)

      /* "pandas/algos.pyx":2083
     *         ndarray data
     *         float64_t* ptr
     *     ngroups = len(counts)             # <<<<<<<<<<<<<<
     *     N, K = (<object> values).shape
     *
     */
      __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_counts)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_ngroups = __pyx_t_1;

     2084:     N, K = (<object> values).shape

      /* "pandas/algos.pyx":2084
     *         float64_t* ptr
     *     ngroups = len(counts)
     *     N, K = (<object> values).shape             # <<<<<<<<<<<<<<
     *
     *     indexer, _counts = groupsort_indexer(labels, ngroups)
     */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L4_unpacking_done;
        __pyx_L3_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L4_unpacking_done:;
      }
      __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_N = __pyx_t_1;
      __pyx_v_K = __pyx_t_7;

     2085:

     2086:     indexer, _counts = groupsort_indexer(labels, ngroups)

      /* "pandas/algos.pyx":2086
     *     N, K = (<object> values).shape
     *
     *     indexer, _counts = groupsort_indexer(labels, ngroups)             # <<<<<<<<<<<<<<
     *     counts[:] = _counts[1:]
     *
     */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_groupsort_indexer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_ngroups); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_labels));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_labels));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_labels));
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L6_unpacking_done:;
      }
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_indexer = __pyx_t_3;
      __pyx_t_3 = 0;
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__counts.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__counts.rcbuffer->pybuffer, (PyObject*)__pyx_v__counts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd__counts.diminfo[0].strides = __pyx_pybuffernd__counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__counts.diminfo[0].shape = __pyx_pybuffernd__counts.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __pyx_v__counts = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     2087:     counts[:] = _counts[1:]

      /* "pandas/algos.pyx":2087
     *
     *     indexer, _counts = groupsort_indexer(labels, ngroups)
     *     counts[:] = _counts[1:]             # <<<<<<<<<<<<<<
     *
     *     data = np.empty((K, N), dtype=np.float64)
     */
      __pyx_t_4 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v__counts), 1, 0, NULL, NULL, &__pyx_slice__31, 1, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);

      /* "pandas/algos.pyx":2087
     *
     *     indexer, _counts = groupsort_indexer(labels, ngroups)
     *     counts[:] = _counts[1:]             # <<<<<<<<<<<<<<
     *
     *     data = np.empty((K, N), dtype=np.float64)
     */
      __pyx_slice__31 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__31);
      __Pyx_GIVEREF(__pyx_slice__31);
      if (__Pyx_PyObject_SetSlice(((PyObject *)__pyx_v_counts), __pyx_t_4, 0, 0, NULL, NULL, &__pyx_slice__32, 0, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_slice__32 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_slice__32);
      __Pyx_GIVEREF(__pyx_slice__32);

     2088:

     2089:     data = np.empty((K, N), dtype=np.float64)

      /* "pandas/algos.pyx":2089
     *     counts[:] = _counts[1:]
     *
     *     data = np.empty((K, N), dtype=np.float64)             # <<<<<<<<<<<<<<
     *     ptr = <float64_t*> data.data
     *
     */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_K); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_data = ((PyArrayObject *)__pyx_t_13);
      __pyx_t_13 = 0;

     2090:     ptr = <float64_t*> data.data

      /* "pandas/algos.pyx":2090
     *
     *     data = np.empty((K, N), dtype=np.float64)
     *     ptr = <float64_t*> data.data             # <<<<<<<<<<<<<<
     *
     *     take_2d_axis1_float64_float64(values.T, indexer, out=data)
     */
      __pyx_v_ptr = ((__pyx_t_5numpy_float64_t *)__pyx_v_data->data);

     2091:

     2092:     take_2d_axis1_float64_float64(values.T, indexer, out=data)

      /* "pandas/algos.pyx":2092
     *     ptr = <float64_t*> data.data
     *
     *     take_2d_axis1_float64_float64(values.T, indexer, out=data)             # <<<<<<<<<<<<<<
     *
     *     for i in range(K):
     */
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_take_2d_axis1_float64_float64); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_values), __pyx_n_s_T); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_indexer);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_indexer);
      __Pyx_GIVEREF(__pyx_v_indexer);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_out, ((PyObject *)__pyx_v_data)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_13, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     2093:

     2094:     for i in range(K):

      /* "pandas/algos.pyx":2094
     *     take_2d_axis1_float64_float64(values.T, indexer, out=data)
     *
     *     for i in range(K):             # <<<<<<<<<<<<<<
     *         # exclude NA group
     *         ptr += _counts[0]
     */
      __pyx_t_7 = __pyx_v_K;
      for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_7; __pyx_t_1+=1) {
        __pyx_v_i = __pyx_t_1;

     2095:         # exclude NA group

     2096:         ptr += _counts[0]

        /* "pandas/algos.pyx":2096
     *     for i in range(K):
     *         # exclude NA group
     *         ptr += _counts[0]             # <<<<<<<<<<<<<<
     *         for j in range(ngroups):
     *             size = _counts[j + 1]
     */
        __pyx_t_14 = 0;
        __pyx_t_9 = -1;
        if (__pyx_t_14 < 0) {
          __pyx_t_14 += __pyx_pybuffernd__counts.diminfo[0].shape;
          if (unlikely(__pyx_t_14 < 0)) __pyx_t_9 = 0;
        } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd__counts.diminfo[0].shape)) __pyx_t_9 = 0;
        if (unlikely(__pyx_t_9 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_9);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_ptr = (__pyx_v_ptr + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd__counts.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd__counts.diminfo[0].strides)));

     2097:         for j in range(ngroups):

        /* "pandas/algos.pyx":2097
     *         # exclude NA group
     *         ptr += _counts[0]
     *         for j in range(ngroups):             # <<<<<<<<<<<<<<
     *             size = _counts[j + 1]
     *             out[j, i] = _median_linear(ptr, size)
     */
        __pyx_t_15 = __pyx_v_ngroups;
        for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
          __pyx_v_j = __pyx_t_16;

     2098:             size = _counts[j + 1]

          /* "pandas/algos.pyx":2098
     *         ptr += _counts[0]
     *         for j in range(ngroups):
     *             size = _counts[j + 1]             # <<<<<<<<<<<<<<
     *             out[j, i] = _median_linear(ptr, size)
     *             ptr += size
     */
          __pyx_t_17 = (__pyx_v_j + 1);
          __pyx_t_9 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd__counts.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd__counts.diminfo[0].shape)) __pyx_t_9 = 0;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_size = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd__counts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd__counts.diminfo[0].strides));

     2099:             out[j, i] = _median_linear(ptr, size)

          /* "pandas/algos.pyx":2099
     *         for j in range(ngroups):
     *             size = _counts[j + 1]
     *             out[j, i] = _median_linear(ptr, size)             # <<<<<<<<<<<<<<
     *             ptr += size
     *
     */
          __pyx_t_18 = __pyx_v_j;
          __pyx_t_19 = __pyx_v_i;
          __pyx_t_9 = -1;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_out.diminfo[0].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_out.diminfo[0].shape)) __pyx_t_9 = 0;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_pybuffernd_out.diminfo[1].shape;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_9 = 1;
          } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_out.diminfo[1].shape)) __pyx_t_9 = 1;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_out.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_out.diminfo[1].strides) = __pyx_f_6pandas_5algos__median_linear(__pyx_v_ptr, __pyx_v_size);

     2100:             ptr += size

          /* "pandas/algos.pyx":2100
     *             size = _counts[j + 1]
     *             out[j, i] = _median_linear(ptr, size)
     *             ptr += size             # <<<<<<<<<<<<<<
     *
     *
     */
          __pyx_v_ptr = (__pyx_v_ptr + __pyx_v_size);
        }
      }

     2101:

     2102:

     2103: cdef inline float64_t _median_linear(float64_t* a, int n):

    /* "pandas/algos.pyx":2103
     *
     *
     * cdef inline float64_t _median_linear(float64_t* a, int n):             # <<<<<<<<<<<<<<
     *     cdef int i, j, na_count = 0
     *     cdef float64_t result
     */

    static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_6pandas_5algos__median_linear(__pyx_t_5numpy_float64_t *__pyx_v_a, int __pyx_v_n) {
      int __pyx_v_i;
      int __pyx_v_j;
      int __pyx_v_na_count;
      __pyx_t_5numpy_float64_t __pyx_v_result;
      __pyx_t_5numpy_float64_t *__pyx_v_tmp;
      __pyx_t_5numpy_float64_t __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_median_linear", 0);

      /* "pandas/algos.pyx":2103
     *
     *
     * cdef inline float64_t _median_linear(float64_t* a, int n):             # <<<<<<<<<<<<<<
     *     cdef int i, j, na_count = 0
     *     cdef float64_t result
     */

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_WriteUnraisable("pandas.algos._median_linear", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     2104:     cdef int i, j, na_count = 0

      /* "pandas/algos.pyx":2104
     *
     * cdef inline float64_t _median_linear(float64_t* a, int n):
     *     cdef int i, j, na_count = 0             # <<<<<<<<<<<<<<
     *     cdef float64_t result
     *     cdef float64_t* tmp
     */
      __pyx_v_na_count = 0;

     2105:     cdef float64_t result

     2106:     cdef float64_t* tmp

     2107:

     2108:     # count NAs

     2109:     for i in range(n):

      /* "pandas/algos.pyx":2109
     *
     *     # count NAs
     *     for i in range(n):             # <<<<<<<<<<<<<<
     *         if a[i] != a[i]:
     *             na_count += 1
     */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
        __pyx_v_i = __pyx_t_2;

     2110:         if a[i] != a[i]:

        /* "pandas/algos.pyx":2110
     *     # count NAs
     *     for i in range(n):
     *         if a[i] != a[i]:             # <<<<<<<<<<<<<<
     *             na_count += 1
     *
     */
        __pyx_t_3 = (((__pyx_v_a[__pyx_v_i]) != (__pyx_v_a[__pyx_v_i])) != 0);
        if (__pyx_t_3) {

     2111:             na_count += 1

          /* "pandas/algos.pyx":2111
     *     for i in range(n):
     *         if a[i] != a[i]:
     *             na_count += 1             # <<<<<<<<<<<<<<
     *
     *     if na_count:
     */
          __pyx_v_na_count = (__pyx_v_na_count + 1);
          goto __pyx_L5;
        }
        __pyx_L5:;
      }

     2112:

     2113:     if na_count:

      /* "pandas/algos.pyx":2113
     *             na_count += 1
     *
     *     if na_count:             # <<<<<<<<<<<<<<
     *         if na_count == n:
     *             return NaN
     */
      __pyx_t_3 = (__pyx_v_na_count != 0);
      if (__pyx_t_3) {

     2114:         if na_count == n:

        /* "pandas/algos.pyx":2114
     *
     *     if na_count:
     *         if na_count == n:             # <<<<<<<<<<<<<<
     *             return NaN
     *
     */
        __pyx_t_3 = ((__pyx_v_na_count == __pyx_v_n) != 0);
        if (__pyx_t_3) {

     2115:             return NaN

          /* "pandas/algos.pyx":2115
     *     if na_count:
     *         if na_count == n:
     *             return NaN             # <<<<<<<<<<<<<<
     *
     *         tmp = <float64_t*> malloc((n - na_count) * sizeof(float64_t))
     */
          __pyx_r = __pyx_v_6pandas_5algos_NaN;
          goto __pyx_L0;
        }

     2116:

     2117:         tmp = <float64_t*> malloc((n - na_count) * sizeof(float64_t))

        /* "pandas/algos.pyx":2117
     *             return NaN
     *
     *         tmp = <float64_t*> malloc((n - na_count) * sizeof(float64_t))             # <<<<<<<<<<<<<<
     *
     *         j = 0
     */
        __pyx_v_tmp = ((__pyx_t_5numpy_float64_t *)malloc(((__pyx_v_n - __pyx_v_na_count) * (sizeof(__pyx_t_5numpy_float64_t)))));

     2118:

     2119:         j = 0

        /* "pandas/algos.pyx":2119
     *         tmp = <float64_t*> malloc((n - na_count) * sizeof(float64_t))
     *
     *         j = 0             # <<<<<<<<<<<<<<
     *         for i in range(n):
     *             if a[i] == a[i]:
     */
        __pyx_v_j = 0;

     2120:         for i in range(n):

        /* "pandas/algos.pyx":2120
     *
     *         j = 0
     *         for i in range(n):             # <<<<<<<<<<<<<<
     *             if a[i] == a[i]:
     *                 tmp[j] = a[i]
     */
        __pyx_t_1 = __pyx_v_n;
        for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
          __pyx_v_i = __pyx_t_2;

     2121:             if a[i] == a[i]:

          /* "pandas/algos.pyx":2121
     *         j = 0
     *         for i in range(n):
     *             if a[i] == a[i]:             # <<<<<<<<<<<<<<
     *                 tmp[j] = a[i]
     *                 j += 1
     */
          __pyx_t_3 = (((__pyx_v_a[__pyx_v_i]) == (__pyx_v_a[__pyx_v_i])) != 0);
          if (__pyx_t_3) {

     2122:                 tmp[j] = a[i]

            /* "pandas/algos.pyx":2122
     *         for i in range(n):
     *             if a[i] == a[i]:
     *                 tmp[j] = a[i]             # <<<<<<<<<<<<<<
     *                 j += 1
     *
     */
            (__pyx_v_tmp[__pyx_v_j]) = (__pyx_v_a[__pyx_v_i]);

     2123:                 j += 1

            /* "pandas/algos.pyx":2123
     *             if a[i] == a[i]:
     *                 tmp[j] = a[i]
     *                 j += 1             # <<<<<<<<<<<<<<
     *
     *         a = tmp
     */
            __pyx_v_j = (__pyx_v_j + 1);
            goto __pyx_L10;
          }
          __pyx_L10:;
        }

     2124:

     2125:         a = tmp

        /* "pandas/algos.pyx":2125
     *                 j += 1
     *
     *         a = tmp             # <<<<<<<<<<<<<<
     *         n -= na_count
     *
     */
        __pyx_v_a = __pyx_v_tmp;

     2126:         n -= na_count

        /* "pandas/algos.pyx":2126
     *
     *         a = tmp
     *         n -= na_count             # <<<<<<<<<<<<<<
     *
     *
     */
        __pyx_v_n = (__pyx_v_n - __pyx_v_na_count);
        goto __pyx_L6;
      }
      __pyx_L6:;

     2127:

     2128:

     2129:     if n % 2:

      /* "pandas/algos.pyx":2129
     *
     *
     *     if n % 2:             # <<<<<<<<<<<<<<
     *         result = kth_smallest_c(a, n / 2, n)
     *     else:
     */
      __pyx_t_3 = (__Pyx_mod_long(__pyx_v_n, 2) != 0);
      if (__pyx_t_3) {

     2130:         result = kth_smallest_c(a, n / 2, n)

        /* "pandas/algos.pyx":2130
     *
     *     if n % 2:
     *         result = kth_smallest_c(a, n / 2, n)             # <<<<<<<<<<<<<<
     *     else:
     *         result = (kth_smallest_c(a, n / 2, n) +
     */
        __pyx_t_4 = __pyx_f_6pandas_5algos_kth_smallest_c(__pyx_v_a, __Pyx_div_long(__pyx_v_n, 2), __pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_result = __pyx_t_5;
        goto __pyx_L11;
      }
      /*else*/ {

     2131:     else:

     2132:         result = (kth_smallest_c(a, n / 2, n) +

        /* "pandas/algos.pyx":2132
     *         result = kth_smallest_c(a, n / 2, n)
     *     else:
     *         result = (kth_smallest_c(a, n / 2, n) +             # <<<<<<<<<<<<<<
     *                   kth_smallest_c(a, n / 2 - 1, n)) / 2
     *
     */
        __pyx_t_4 = __pyx_f_6pandas_5algos_kth_smallest_c(__pyx_v_a, __Pyx_div_long(__pyx_v_n, 2), __pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);

        /* "pandas/algos.pyx":2132
     *         result = kth_smallest_c(a, n / 2, n)
     *     else:
     *         result = (kth_smallest_c(a, n / 2, n) +             # <<<<<<<<<<<<<<
     *                   kth_smallest_c(a, n / 2 - 1, n)) / 2
     *
     */
        __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

     2133:                   kth_smallest_c(a, n / 2 - 1, n)) / 2

        /* "pandas/algos.pyx":2133
     *     else:
     *         result = (kth_smallest_c(a, n / 2, n) +
     *                   kth_smallest_c(a, n / 2 - 1, n)) / 2             # <<<<<<<<<<<<<<
     *
     *     if na_count:
     */
        __pyx_t_6 = __pyx_f_6pandas_5algos_kth_smallest_c(__pyx_v_a, (__Pyx_div_long(__pyx_v_n, 2) - 1), __pyx_v_n); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);

        /* "pandas/algos.pyx":2133
     *     else:
     *         result = (kth_smallest_c(a, n / 2, n) +
     *                   kth_smallest_c(a, n / 2 - 1, n)) / 2             # <<<<<<<<<<<<<<
     *
     *     if na_count:
     */
        __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_int_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_5 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_v_result = __pyx_t_5;
      }
      __pyx_L11:;

     2134:

     2135:     if na_count:

      /* "pandas/algos.pyx":2135
     *                   kth_smallest_c(a, n / 2 - 1, n)) / 2
     *
     *     if na_count:             # <<<<<<<<<<<<<<
     *         free(a)
     *
     */
      __pyx_t_3 = (__pyx_v_na_count != 0);
      if (__pyx_t_3) {

     2136:         free(a)

        /* "pandas/algos.pyx":2136
     *
     *     if na_count:
     *         free(a)             # <<<<<<<<<<<<<<
     *
     *     return result
     */
        free(__pyx_v_a);
        goto __pyx_L12;
      }
      __pyx_L12:;

     2137:

     2138:     return result

      /* "pandas/algos.pyx":2138
     *         free(a)
     *
     *     return result             # <<<<<<<<<<<<<<
     *
     * include "join.pyx"
     */
      __pyx_r = __pyx_v_result;
      goto __pyx_L0;

     2139:

     2140: include "join.pyx"

     2141: include "generated.pyx"