小编J-m*_*man的帖子

Geopandas 为绘图上的点添加标签

我有一个带有几何列和带有点名称的列的地理数据框“all_locations”。在地图上绘制点效果很好,但我想用位置名称注释点。


['位置'] ['几何']
BUITHVN8 POINT()

(当然,实际数据框要大得多)

我试过这个(和其他事情):

    all_locations['coords'] = all_locations['geometry'].apply(lambda x: x.point.coords[:])
all_locations['coords'] = [coords[0] for coords in all_locations['coords']]

all_locations.plot(ax=ax)
for idx, row in all_locations.iterrows():
    plt.annotate(s=row['locatie'], xy=row['geometry'])
Run Code Online (Sandbox Code Playgroud)

添加坐标列但它给出了这个错误:“点”对象没有属性“点”

python-3.x geopandas

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

Pandas:无法将日期时间 YYYY-mm-dd 转换为 dd-mm-YYYY

我有一个 pandas 数据框,其中包含日期列(datetime64[ns] 格式),日期列为 yyyy-mm-dd (如 2018-09-12)。我想将其转换为 dd-mm-yyyy 但我尝试的似乎不起作用:

pd.to_datetime(df['date'], format='%d-%m-%Y')
0    2018-09-12
1    2018-09-12
Run Code Online (Sandbox Code Playgroud)

编辑:添加示例 df

df.head(3)
        date      nr
0   2018-09-12   144
1   2018-09-12    37
2   2018-09-12    28

df.info()
date   datetime64[ns]
nr     int
Run Code Online (Sandbox Code Playgroud)

“日期”不包含任何 Nan 或 Nat

python string datetime series pandas

2
推荐指数
1
解决办法
8951
查看次数

标签 统计

datetime ×1

geopandas ×1

pandas ×1

python ×1

python-3.x ×1

series ×1

string ×1