環境:
- 蟒蛇 3.10
- 地理熊貓 0.10.2
- PostgreSQL 14.2.2
代碼:
import pandas as pd
import geopandas as gpd
from sqlalchemy import create_engine
x = pd.read_csv("./ships.csv")
x = gpd.GeoDataFrame(x, geometry=gpd.points_from_xy(x.LON, x.LAT))
engine = create_engine("postgresql://postgres:root@localhost/db")
x.to_postgis('ships', engine, index=False)
結果:
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "idx_ships_geometry" already exists
[SQL: CREATE INDEX idx_ships_geometry ON public.ships USING gist (geometry)]
(Background on this error at: https://sqlalche.me/e/14/f405)
uj5u.com熱心網友回復:
這是由 GeoAlchemy 0.11 引起的已知錯誤。在 GeoAlchemy 中修復此問題之前,請使用舊版本 0.10.2 使其作業。有關詳細資訊,請參閱https://github.com/geopandas/geopandas/issues/2375。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/451178.html
標籤:python-3.x PostgreSQL sqlalchemy 大熊猫
