pandas:内部函数的错误参数(在iterators.c中)

时间:2014-05-02 18:08:17

标签: python pandas

为什么我在这里收到错误?使用Python 2.6和pandas v.0.13.1

In [2]: df = pd.DataFrame({'x': [1, 1, 2, 2, 1, 1], 'y':[1, 2, 2, 2, 2, 1]})

In [3]: print pd.factorize(pd.lib.fast_zip([df.x, df.y]))[0]
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-3-d98d985f2794> in <module>()
----> 1 print pd.factorize(pd.lib.fast_zip([df.x, df.y]))[0]

/usr/lib64/python2.6/site-packages/pandas/lib.so in pandas.lib.fast_zip (pandas/lib.c:8026)()

SystemError: numpy/core/src/multiarray/iterators.c:370: bad argument to internal function

1 个答案:

答案 0 :(得分:2)

您必须使用df.x.valuesdf.y.values来访问np.ndarray中所需的pd.lib.fast_zip()个对象:

print(pd.factorize(pd.lib.fast_zip([df.x.values, df.y.values]))[0])