Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct mismatched bus id #991

Merged
merged 11 commits into from
Nov 15, 2022
Prev Previous commit
Next Next commit
Black&isort
  • Loading branch information
nailend committed Oct 19, 2022
commit c750c990b26f8bf2f28378b1122fdf853989efd9
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@

from geoalchemy2 import Geometry
from geoalchemy2.shape import to_shape
from psycopg2.extensions import AsIs, register_adapter
from sqlalchemy import REAL, Column, Integer, String, func
from sqlalchemy.ext.declarative import declarative_base
import geopandas as gpd
Expand Down Expand Up @@ -192,7 +193,6 @@
from egon.data.datasets.heat_demand_timeseries import EgonEtragoHeatCts
from egon.data.datasets.zensus_mv_grid_districts import MapZensusGridDistricts
from egon.data.datasets.zensus_vg250 import DestatisZensusPopulationPerHa
from psycopg2.extensions import AsIs, register_adapter

engine = db.engine()
Base = declarative_base()
Expand Down Expand Up @@ -1332,18 +1332,22 @@ def adapt_numpy_int64(numpy_int64):
with db.session_scope() as session:
query = session.query(
egon_map_zensus_buildings_filtered_all.id,
egon_map_zensus_buildings_filtered_all.zensus_population_id
).filter(egon_map_zensus_buildings_filtered_all.id.in_(
df_cts_buildings.id.values))
egon_map_zensus_buildings_filtered_all.zensus_population_id,
).filter(
egon_map_zensus_buildings_filtered_all.id.in_(
df_cts_buildings.id.values
)
)

df_map_zensus_population_id = pd.read_sql(
query.statement, session.connection(), index_col=None
)

df_cts_buildings = pd.merge(left=df_cts_buildings.drop(
columns="zensus_population_id"),
df_cts_buildings = pd.merge(
left=df_cts_buildings.drop(columns="zensus_population_id"),
right=df_map_zensus_population_id,
on="id")
on="id",
)

# Write table to db for debugging and postprocessing
write_table_to_postgis(
Expand Down