File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -135,9 +135,8 @@ cdef class Reducer:
135135 else :
136136 res = self .f(chunk)
137137
138- if (not _is_sparse_array(res) and hasattr (res, ' values' )
139- and util.is_array(res.values)):
140- res = res.values
138+ # TODO: reason for not squeezing here?
139+ res = _extract_result(res, squeeze = False )
141140 if i == 0 :
142141 # On the first pass, we check the output shape to see
143142 # if this looks like a reduction.
@@ -402,18 +401,17 @@ cdef class SeriesGrouper(_BaseGrouper):
402401 return result, counts
403402
404403
405- cdef inline _extract_result(object res):
404+ cdef inline _extract_result(object res, bint squeeze = True ):
406405 """ extract the result object, it might be a 0-dim ndarray
407406 or a len-1 0-dim, or a scalar """
408407 if (not _is_sparse_array(res) and hasattr (res, ' values' )
409408 and util.is_array(res.values)):
410409 res = res.values
411- if not np.isscalar(res):
412- if util.is_array(res):
413- if res.ndim == 0 :
414- res = res.item()
415- elif res.ndim == 1 and len (res) == 1 :
416- res = res[0 ]
410+ if util.is_array(res):
411+ if res.ndim == 0 :
412+ res = res.item()
413+ elif squeeze and res.ndim == 1 and len (res) == 1 :
414+ res = res[0 ]
417415 return res
418416
419417
You can’t perform that action at this time.
0 commit comments