提取特定方向python的XY线

2024-06-28 11:02:18 发布

您现在位置:Python中文网/ 问答频道 /正文

现在我有了一个新的数据集,前2列是X和Y点(通常它们表示位置)。数据文件非常大,对于初始数据分析,我需要提取特定的行(或接近行的数据)-有没有任何方法可以告诉numpy(或者python,或者pandas)来提取这个特定的数据集-附件是一个例子,这是简化的,数据是相当全面的(这不是真实数据的情况),但将清楚地表明我需要:

示例编辑*

import os
import sys
import numpy as np
X = list(range(45))*3 
Y = list(range(1, 91, 2)) + list(range(20, 65, 1)) + list(range(1, 136, 3))   
XY = zip(X, Y)
XYarray = np.array(XY).reshape(135, 2)
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.plot(XYarray[:,0], XYarray[:,1], 'ro') #all data
plt.plot(XYarray[0:44,0], XYarray[0:44,1], 'b*') #first line to be teste
#plt.plot(XYarray[45:90,0], XYarray[45:90,1], 'g*') #other lines of interest
#plt.plot(XYarray[91:135,0], XYarray[91:135,1], 'gx') #otherline of ineters
fig.show()

我所有的数据都在一个任意的XY数组(表面空间数据)中—我需要提取可用的行;例如,我只想提取未注释的蓝星线—然后移动下一行(当前在代码中注释) 请记住,我的实际数据并不是那么规律 希望有帮助


Tags: of数据方法importnumpyplot数据文件as