@@ -23,6 +23,15 @@ from pandas._libs.util cimport (
2323
2424from pandas._libs.lib import is_scalar
2525
26+ # Accessing the data member of ndarray is deprecated, but we depend on it.
27+ cdef extern from * :
28+ """
29+ static void PyArray_SET_DATA(PyArrayObject *arr, void * data) {
30+ arr->data = data;
31+ }
32+ """
33+ void PyArray_SET_DATA(ndarray arr, void * data)
34+
2635
2736cdef cnp.dtype _dtype_obj = np.dtype(" object" )
2837
@@ -340,18 +349,18 @@ cdef class Slider:
340349 self .stride = values.strides[0 ]
341350 self .orig_data = self .buf.data
342351
343- self .buf.data = self .values.data
352+ PyArray_SET_DATA( self .buf, self .values.data)
344353 self .buf.strides[0 ] = self .stride
345354
346355 cdef move(self , int start, int end):
347356 """
348357 For slicing
349358 """
350- self .buf.data = self .values.data + self .stride * start
359+ PyArray_SET_DATA( self .buf, self .values.data + self .stride * start)
351360 self .buf.shape[0 ] = end - start
352361
353362 cdef reset(self ):
354- self .buf.data = self .orig_data
363+ PyArray_SET_DATA( self .buf, self .orig_data)
355364 self .buf.shape[0 ] = 0
356365
357366
@@ -469,7 +478,7 @@ cdef class BlockSlider:
469478 arr = self .blk_values[i]
470479
471480 # axis=1 is the frame's axis=0
472- arr.data = self .base_ptrs[i] + arr.strides[1 ] * start
481+ PyArray_SET_DATA( arr, self .base_ptrs[i] + arr.strides[1 ] * start)
473482 arr.shape[1 ] = end - start
474483
475484 # move and set the index
@@ -490,7 +499,7 @@ cdef class BlockSlider:
490499 arr = self .blk_values[i]
491500
492501 # axis=1 is the frame's axis=0
493- arr.data = self .base_ptrs[i]
502+ PyArray_SET_DATA( arr, self .base_ptrs[i])
494503 arr.shape[1 ] = 0
495504
496505 cdef _restore_blocks(self ):
0 commit comments