小编mm_*_*der的帖子

将点转换为线 Geopandas

您好,我正在尝试将 X 和 Y 坐标列表转换为线。我想通过groupbyID 和时间映射这些数据。只要我grouby一列,我的代码就会成功执行,但两列是我遇到错误的地方。我参考了这个问题

以下是一些示例数据:

ID  X           Y           Hour
1   -87.78976   41.97658    16
1   -87.66991   41.92355    16
1   -87.59887   41.708447   17
2   -87.73956   41.876827   16
2   -87.68161   41.79886    16
2   -87.5999    41.7083     16
3   -87.59918   41.708485   17
3   -87.59857   41.708393   17
3   -87.64391   41.675133   17
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

df = pd.read_csv("snow_gps.csv", sep=';')

#zip the coordinates into a point object and convert to a GeoData Frame
geometry = [Point(xy) for xy in zip(df.X, df.Y)]
geo_df …
Run Code Online (Sandbox Code Playgroud)

python pandas geopandas

8
推荐指数
1
解决办法
1万
查看次数

Python bson:如何在新列中创建 ObjectId 列表

我有一个 CSV,我需要在 python 中创建一列随机唯一的 MongoDB id。

这是我的 csv 文件:

   import pandas as pd

   df = pd.read_csv('file.csv', sep=';')
   print(df)

        Zone
        Zone_1
        Zone_2
Run Code Online (Sandbox Code Playgroud)

我目前正在使用这行代码来生成唯一的ObjectId-更新

import bson

x = bson.objectid.ObjectId()
df['objectids'] = x
print(df)

Zone; objectids
Zone_1; 5bce2e42f6738f20cc12518d
Zone_2; 5bce2e42f6738f20cc12518d
Run Code Online (Sandbox Code Playgroud)

如何使每一行的 ObjectId 都是唯一的?

python bson pymongo

7
推荐指数
1
解决办法
9729
查看次数

标签 统计

python ×2

bson ×1

geopandas ×1

pandas ×1

pymongo ×1