Geopandas: AttributeError: 'Transaction' object has no attribute 'run_callable'

Geopandas: AttributeError: 'Transaction' object has no attribute 'run_callable'

我需要有关此错误的帮助,AttributeError:'Transaction' 对象没有属性 'run_callable'

from sqlalchemy import create_engine
import pandas as pd


def insert(df):
    calidades_df = df.copy()
    calidades_df.insert(loc=0, column='proceso', value=p['proceso'])
    calidades_df.insert(
        loc=len(calidades_df.columns),
        column='baja',
        value=False)

    engine = create_engine(
        "postgres://usr:pass#@localhost:5432/database"
    )
    with engine.begin() as conn:
        calidades_df.to_postgis(
            'calidades',
            conn,
            schema='ndvi',
            if_exists='append',
            index=False
            )

错误仅在使用带有 to_postgis() 函数的 geopandas 数据框时发生。对于 pandas 数据帧,使用 to_sql() 函数可以正常工作。提前致谢

我无意中遇到了同样的问题,to_postgis() 方法似乎有问题。所以我所做的是实现 https://gis.stackexchange.com/a/239231/36712,它使用 pandas 中的 to_sql()。你只需要将你的几何变成 WKT 并为几何列定义一个数据类型。