From f5c89c63390d419eb4e5e760d3e120bc0989b753 Mon Sep 17 00:00:00 2001 From: Matt Richards <45483497+m-richards@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:06:51 +1000 Subject: [PATCH] TST: add test to close GH1852 (#2519) --- geopandas/tests/test_pandas_methods.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/geopandas/tests/test_pandas_methods.py b/geopandas/tests/test_pandas_methods.py index 552d53b..90a4aa9 100644 --- a/geopandas/tests/test_pandas_methods.py +++ b/geopandas/tests/test_pandas_methods.py @@ -663,6 +663,24 @@ def test_df_apply_returning_series(df): assert result.dtype == "object" +def test_df_apply_geometry_dtypes(df): + # https://github.com/geopandas/geopandas/issues/1852 + apply_types = [] + + def get_dtypes(srs): + apply_types.append((srs.name, type(srs))) + + df["geom2"] = df.geometry + df.apply(get_dtypes) + expected = [ + ("geometry", GeoSeries), + ("value1", pd.Series), + ("value2", pd.Series), + ("geom2", GeoSeries), + ] + assert apply_types == expected + + def test_pivot(df): # https://github.com/geopandas/geopandas/issues/2057 # pivot failing due to creating a MultiIndex