我有一个文本文件,看起来像这样
,A,B
0,"[[-81.03443909 29.22855949]
[-81.09729767 29.27094078]
[-80.9937973 29.19698906]
[-81.03072357 29.27445984]
[-81.00499725 29.22187805]]","[[-81.42427063 28.30874634]
[-81.42427063 28.30874634]
[-81.42427063 28.30874634]
[-81.36068726 28.29172897]
[-81.42297363 28.30497551]
[-81.48571777 28.24975777]
[-81.35914612 28.29036331]]"
这就是我使用的^{cd1>}在放入熊猫数据帧之后的样子
^{pr2}$我想它看起来像这样
^{pr3}$在创建.txt文件之前,数据位于^{cd2>}中,我使用熊猫创建文本文件。所以,也许有一种方法可以跳过txt文件,并使用熊猫将数组拆分或格式化为一个整洁的数据帧。我在这干了一段时间了,我搞不懂怎么做。
这就是我如何生成数据的。我只复制2列来保持清晰,但将来我想传递一个唯一的点标识符
^{pr4}$这是^{cd3>}的输出
[array([[-81.03443909, 29.22855949],
[-81.09729767, 29.27094078],
[-81.42297363, 28.30497551],
[-81.48571777, 28.24975777],
[-81.35914612, 28.29036331]], dtype=float32), array([[-81.49134064, 27.58896065],
[-81.5194931 , 27.63422012],
[-81.5096283 , 27.55581093],
[-82.05444336, 26.93555069]], dtype=float32), array([[-82.18956757, 26.52433586],
[-82.18956757, 26.52433586],
[-82.18956757, 26.52433586],
[-82.19439697, 26.53297997]], dtype=float32)]
这就是我如何创建数据帧并编写^{cd4>}文件
clusters = pd.DataFrame({'A':[clusters]})
clusters.to_csv('output.txt')
这是一个起点:
或者使用多重索引:
^{pr2}$相关问题 更多 >
编程相关推荐