@@ -203,7 +203,8 @@ cdef class SeriesBinGrouper:
203
203
self .f = f
204
204
205
205
values = series.values
206
- if not values.flags.c_contiguous:
206
+ if util.is_array(values) and not values.flags.c_contiguous:
207
+ # e.g. Categorical has no `flags` attribute
207
208
values = values.copy(' C' )
208
209
self .arr = values
209
210
self .typ = series._constructor
@@ -230,7 +231,8 @@ cdef class SeriesBinGrouper:
230
231
values = dummy.values
231
232
if values.dtype != self .arr.dtype:
232
233
raise ValueError (' Dummy array must be same dtype' )
233
- if not values.flags.contiguous:
234
+ if util.is_array(values) and not values.flags.contiguous:
235
+ # e.g. Categorical has no `flags` attribute
234
236
values = values.copy()
235
237
index = dummy.index.values
236
238
if not index.flags.contiguous:
@@ -332,7 +334,8 @@ cdef class SeriesGrouper:
332
334
self .f = f
333
335
334
336
values = series.values
335
- if not values.flags.c_contiguous:
337
+ if util.is_array(values) and not values.flags.c_contiguous:
338
+ # e.g. Categorical has no `flags` attribute
336
339
values = values.copy(' C' )
337
340
self .arr = values
338
341
self .typ = series._constructor
@@ -356,7 +359,8 @@ cdef class SeriesGrouper:
356
359
if (dummy.dtype != self .arr.dtype
357
360
and values.dtype != self .arr.dtype):
358
361
raise ValueError (' Dummy array must be same dtype' )
359
- if not values.flags.contiguous:
362
+ if util.is_array(values) and not values.flags.contiguous:
363
+ # e.g. Categorical has no `flags` attribute
360
364
values = values.copy()
361
365
index = dummy.index.values
362
366
if not index.flags.contiguous:
@@ -467,12 +471,13 @@ cdef class Slider:
467
471
char * orig_data
468
472
469
473
def __init__ (self , object values , object buf ):
470
- assert (values.ndim == 1 )
474
+ assert (values.ndim == 1 )
471
475
472
- if not values.flags.contiguous:
476
+ if util.is_array(values) and not values.flags.contiguous:
477
+ # e.g. Categorical has no `flags` attribute
473
478
values = values.copy()
474
479
475
- assert (values.dtype == buf.dtype)
480
+ assert (values.dtype == buf.dtype)
476
481
self .values = values
477
482
self .buf = buf
478
483
self .stride = values.strides[0 ]
0 commit comments