Skip to content

pd.concat with GeoDataFrames #1396

@zmoon

Description

@zmoon
import geopandas as gpd
import pandas as pd
from shapely import Point

gdf1 = gpd.GeoDataFrame(geometry=[Point(0, 0)])
gdf2 = gpd.GeoDataFrame(geometry=[Point(1, 1)])

gdf: gpd.GeoDataFrame = pd.concat([gdf1, gdf2], ignore_index=True)
assert isinstance(gdf, gpd.GeoDataFrame)
print(gdf)
      geometry
0  POINT (0 0)
1  POINT (1 1)
t.py:8: error: Incompatible types in assignment (expression has type "DataFrame", variable has type "GeoDataFrame")  [assignment]
Found 1 error in 1 file (checked 1 source file)
  • pandas-stubs 2.3.2.250926
  • mypy 1.18.2
  • geopandas 1.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions