You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explanation: assume you have an ExtensionArray with list-like values (eg with an object numpy array with lists under the hood). When calling, to_csv, which goes through Block.to_native_types, we convert this to a numpy array and call astype(str):
But, in numpy, if you have a numpy array with list like values, doing astype(str) does not work:
In [2]: a = np.array([[1, 2], [3]], dtype=object)
In [3]: a.astype(str)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-db38302b5f9a> in <module>
----> 1 a.astype(str)
ValueError: setting an array element with a sequence
This could be considered a numpy issue, but, we should also avoid converting to a numpy array while we can directly call astype on the ExtensionArray.
The text was updated successfully, but these errors were encountered:
From a report at GeoPandas: geopandas/geopandas#1145
Explanation: assume you have an ExtensionArray with list-like values (eg with an object numpy array with lists under the hood). When calling,
to_csv
, which goes throughBlock.to_native_types
, we convert this to a numpy array and callastype(str)
:pandas/pandas/core/internals/blocks.py
Line 699 in 39602e7
But, in numpy, if you have a numpy array with list like values, doing
astype(str)
does not work:This could be considered a numpy issue, but, we should also avoid converting to a numpy array while we can directly call
astype
on the ExtensionArray.The text was updated successfully, but these errors were encountered: