From 8f4889affd4de5dc60bb3ad2104c1f9b577c031b Mon Sep 17 00:00:00 2001 From: abonte <6319051+abonte@users.noreply.github.com> Date: Sun, 31 May 2020 11:16:38 +0200 Subject: [PATCH] DOC: Add example in GeoDataFrame docstring (#1456) * add example in GeoDataFrame docstring * Update GeoDataFrame docstring Co-authored-by: Martin Fleischmann Co-authored-by: Martin Fleischmann --- geopandas/geodataframe.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py index db1931a..9060cbb 100644 --- a/geopandas/geodataframe.py +++ b/geopandas/geodataframe.py @@ -58,6 +58,25 @@ class GeoDataFrame(GeoPandasBase, DataFrame): geometry : str or array (optional) If str, column to use as geometry. If array, will be set as 'geometry' column on GeoDataFrame. + + Examples + -------- + Constructing GeoDataFrame from a dictionary. + + >>> d = {'col1': ['name1', 'name2'], + ... 'geometry': [shapely.geometry.Point(1,2), shapely.geometry.Point(2,1)]} + >>> gdf = gpd.GeoDataFrame(d, crs="EPSG:4326") + >>> gdf + col1 geometry + 0 name1 POINT (1.00000 2.00000) + 1 name2 POINT (2.00000 1.00000) + + Notice that the inferred dtype of 'geometry' columns is geometry. + + >>> gdf.dtypes + col1 object + geometry geometry + dtype: object """ _metadata = ["_crs", "_geometry_column_name"]