- 
                Notifications
    You must be signed in to change notification settings 
- Fork 43
Closed
Description
Originally reported in geopandas/geopandas#1879.
from_wkt works as expected on a numpy array of strings.
>>> np.array(["POINT (0 0)"])
array(['POINT (0 0)'], dtype='<U11')
>>> pygeos.from_wkt(np.array(["POINT (0 0)"]))
array([<pygeos.Geometry POINT (0 0)>], dtype=object)But if I use a pandas StringArray, from_wkt produces an error.
>>> pd.array(["POINT (0 0)"])
<StringArray>
['POINT (0 0)']
Length: 1, dtype: string
>>> pygeos.from_wkt(pd.array(["POINT (0 0)"]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Caskroom/miniconda/base/envs/geopandas-dev/lib/python3.9/site-packages/pygeos/io.py", line 181, in from_wkt
    return lib.from_wkt(geometry, **kwargs)
  File "/usr/local/Caskroom/miniconda/base/envs/geopandas-dev/lib/python3.9/site-packages/pandas/core/arrays/numpy_.py", line 254, in __array_ufunc__
    result = type(self)(result)
  File "/usr/local/Caskroom/miniconda/base/envs/geopandas-dev/lib/python3.9/site-packages/pandas/core/arrays/string_.py", line 195, in __init__
    self._validate()
  File "/usr/local/Caskroom/miniconda/base/envs/geopandas-dev/lib/python3.9/site-packages/pandas/core/arrays/string_.py", line 200, in _validate
    raise ValueError("StringArray requires a sequence of strings or pandas.NA")
ValueError: StringArray requires a sequence of strings or pandas.NAThe error is being raised from the _validate() method on the StringArray, but when I call that on my StringArray I don't get an error.
>>> pd.array(["POINT (0 0)"])._validate()
>>>I guess somewhere in between me calling pygeos.from_wkt and the StringArray._validate() a new invalid StringArray is being created? I don't know enough about the internals of pygeos to know where to go from there.
The question I have is: is pandas StringArray a supported input type? I would understand if not; it is still considered "experimental".
Metadata
Metadata
Assignees
Labels
No labels