From 3c5c569c94ab5b63dd5be7af30e4e31bcf4e346b Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 13 Jun 2020 18:36:11 +0200 Subject: [PATCH] BUG: fix astype('string') (#1469) --- geopandas/array.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/geopandas/array.py b/geopandas/array.py index 3391392..09e2df3 100644 --- a/geopandas/array.py +++ b/geopandas/array.py @@ -784,7 +784,13 @@ class GeometryArray(ExtensionArray): elif pd.api.types.is_string_dtype(dtype) and not pd.api.types.is_object_dtype( dtype ): - return to_wkt(self).astype(dtype, copy=False) + values = to_wkt(self).astype(dtype, copy=False) + if compat.PANDAS_GE_10: + pd_dtype = pd.api.types.pandas_dtype(dtype) + if isinstance(pd_dtype, pd.StringDtype): + # ensure to return a pandas string array instead of numpy array + return pd.array(values, dtype="string") + return values else: return np.array(self, dtype=dtype, copy=copy)