在python中从csv数据集中提取ID和相关数据
为我最后一年的项目做一个计划。 该程序从.csv数据集中获取经度和纬度坐标,并将其绘制在地图上。 我遇到的问题是有多个ID,总计445000+分 我如何改进它,使程序能够区分ID在python中从csv数据集中提取ID和相关数据,python,pandas,numpy,csv,Python,Pandas,Numpy,Csv,为我最后一年的项目做一个计划。 该程序从.csv数据集中获取经度和纬度坐标,并将其绘制在地图上。 我遇到的问题是有多个ID,总计445000+分 我如何改进它,使程序能够区分ID def create_image(self, color, width=2): # Creates an image that contains the Map and the GPS record # color = color the GPS line is # width = width
def create_image(self, color, width=2):
# Creates an image that contains the Map and the GPS record
# color = color the GPS line is
# width = width of the GPS line
data = pd.read_csv(self.data_path, header=0)
# sep will separate the latitude from the longitude
data.info()
self.result_image = Image.open(self.map_path, 'r')
img_points = []
gps_data = tuple(zip(data['latitude'].values, data['longitude'].values))
for d in gps_data:
x1, y1 = self.scale_to_img(d, (self.result_image.size[0], self.result_image.size[1]))
img_points.append((x1, y1))
draw = ImageDraw.Draw(self.result_image)
draw.line(img_points, fill=color, width=width)
我还附上了该程序的工作原理,但我只是想尽量减少它一次打印多少用户
提前感谢。要检查特定ID,您可以创建一个筛选器。对于此数据帧
long lat ID
0 10 5 test1
1 15 20 test2
您可以执行以下操作:
id_filt = df_data['ID'] == 'test1'
这可用于从数据帧中筛选出ID为“test1”的每个条目
df_data[id_filt]
long lat ID
10 5 test1
能否提供数据框中的片段。ID是它的一部分吗?这个问题与
tkinter
有关吗?我看不到任何与tkinter相关的代码。对不起,是的,GUI正在使用tkinter,主执行命令来自tkinter端。@PonyTale是否来自.csv文件?因为这个ID被称为iPhoneUID。我还没有实现它,因为我不确定如何解决这个问题。我将把数据集添加到GitHub@JagerScouser你认为一个人需要知道如何使用tkinter
来解决你的问题吗?据我所知,这个问题可以在几乎不了解tkinter的情况下解决。如果我的回答正确,请删除tkinter
标签