@@ -75,57 +75,6 @@ def group_nth_object(ndarray[object, ndim=2] out,
7575 out[i, j] = resx[i, j]
7676
7777
78- @ cython.boundscheck (False )
79- @ cython.wraparound (False )
80- def group_nth_bin_object (ndarray[object , ndim = 2 ] out,
81- ndarray[int64_t] counts ,
82- ndarray[object , ndim = 2 ] values,
83- ndarray[int64_t] bins , int64_t rank ):
84- """
85- Only aggregates on axis=0
86- """
87- cdef:
88- Py_ssize_t i, j, N, K, ngroups, b
89- object val
90- float64_t count
91- ndarray[object , ndim= 2 ] resx
92- ndarray[float64_t, ndim= 2 ] nobs
93-
94- nobs = np.zeros((< object > out).shape, dtype = np.float64)
95- resx = np.empty((< object > out).shape, dtype = object )
96-
97- if len (bins) == 0 :
98- return
99- if bins[len (bins) - 1 ] == len (values):
100- ngroups = len (bins)
101- else :
102- ngroups = len (bins) + 1
103-
104- N, K = (< object > values).shape
105-
106- b = 0
107- for i in range (N):
108- while b < ngroups - 1 and i >= bins[b]:
109- b += 1
110-
111- counts[b] += 1
112- for j in range (K):
113- val = values[i, j]
114-
115- # not nan
116- if val == val:
117- nobs[b, j] += 1
118- if nobs[b, j] == rank:
119- resx[b, j] = val
120-
121- for i in range (ngroups):
122- for j in range (K):
123- if nobs[i, j] == 0 :
124- out[i, j] = nan
125- else :
126- out[i, j] = resx[i, j]
127-
128-
12978@ cython.boundscheck (False )
13079@ cython.wraparound (False )
13180def group_last_object (ndarray[object , ndim = 2 ] out,
@@ -169,56 +118,6 @@ def group_last_object(ndarray[object, ndim=2] out,
169118 out[i, j] = resx[i, j]
170119
171120
172- @ cython.boundscheck (False )
173- @ cython.wraparound (False )
174- def group_last_bin_object (ndarray[object , ndim = 2 ] out,
175- ndarray[int64_t] counts ,
176- ndarray[object , ndim = 2 ] values,
177- ndarray[int64_t] bins ):
178- """
179- Only aggregates on axis=0
180- """
181- cdef:
182- Py_ssize_t i, j, N, K, ngroups, b
183- object val
184- float64_t count
185- ndarray[object , ndim= 2 ] resx
186- ndarray[float64_t, ndim= 2 ] nobs
187-
188- nobs = np.zeros((< object > out).shape, dtype = np.float64)
189- resx = np.empty((< object > out).shape, dtype = object )
190-
191- if len (bins) == 0 :
192- return
193- if bins[len (bins) - 1 ] == len (values):
194- ngroups = len (bins)
195- else :
196- ngroups = len (bins) + 1
197-
198- N, K = (< object > values).shape
199-
200- b = 0
201- for i in range (N):
202- while b < ngroups - 1 and i >= bins[b]:
203- b += 1
204-
205- counts[b] += 1
206- for j in range (K):
207- val = values[i, j]
208-
209- # not nan
210- if val == val:
211- nobs[b, j] += 1
212- resx[b, j] = val
213-
214- for i in range (ngroups):
215- for j in range (K):
216- if nobs[i, j] == 0 :
217- out[i, j] = nan
218- else :
219- out[i, j] = resx[i, j]
220-
221-
222121cdef inline float64_t _median_linear(float64_t* a, int n) nogil:
223122 cdef int i, j, na_count = 0
224123 cdef float64_t result
0 commit comments