BUG: fix astype('string') (#1469)

This commit is contained in:
Joris Van den Bossche authored and GitHub committed 2020-06-13 18:36:11 +02:00
1 parent 72c57c0e55
commit 3c5c569c94
1 file changed
+7 -1
+7 -1
View File
@@ -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)