我是一名有用的助手,可以为您翻译文本。
我正在尝试基于pandas数据帧的两列找到一系列点的凸包。
我的当前代码是:
# Create column of point co-ordinates
df['xy'] = df.apply(lambda x: [x['col_1'], x['col_2']], axis=1)
# Return a numpy array of the point coordinates
point_list = df.xy.values
# pass the list to ConvexHull (imported using: from scipy.spatial import ConvexHull)
hull = ConvexHull(point_list)
当我运行时,出现以下错误:
Traceback (most recent call last):
File "<ipython-input-41-517201a29182>", line 1, in <module>
hull = ConvexHull(point_list)
File "qhull.pyx", line 2220, in scipy.spatial.qhull.ConvexHull.__init__ (scipy\spatial\qhull.c:19058)
File "C:\Users\****\AppData\Local\Continuum\Anaconda\lib\site- packages\numpy\core\numeric.py", line 550, in ascontiguousarray
return array(a, dtype, copy=False, order='C', ndmin=1)
ValueError: setting an array element with a sequence.
对此有何想法?
最好的问候,