mirror of
https://github.com/wassname/geopandas.git
synced 2026-10-03 12:31:14 +08:00
BUG: fix astype('string') (#1469)
This commit is contained in:
1 parent
72c57c0e55
commit
3c5c569c94
1 file changed
+7
-1
+7
-1
@@ -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)
|
||||
|
||||
|
||||
Reference in new issue
Block a user