I created a pandas dataframe with pd.DataFrame({"A": ["dog", "cat"]}) and sent to a c extension the resulting numpy array. In C, I do:
PyArrayObject * pArray = (PyArrayObject *) pArrayObj;
PyArray_Descr * pDesc = PyArray_DTYPE(pArray);
int kind = pDesc->kind;
npy_intp sz = PyArray_DIM(pArray, 0);
PyObject * p0 = (PyObject *) PyArray_GETPTR1(pArray, 0);
In the above 'kind' contains 'O' (for object array) and sz = 2 (as expected). However p0 does not seem to access the first object:
(gdb) p *p0
$10 = {ob_refcnt = 140737227161872, ob_type = 0x7ffff06e8180}
Notice corrupted refcnt and unresolved ob_type (was expecting PyUnicode_Type).
Any suggestions to correctly obtain a pointer to each element?
I'm using numpy 1.14 on Centos 7, g++ 6.2.1