Skip to content

Commit 3f54198

Browse files
committed
Interpret astype(object) as 'cast to an array of numpy arrays'
1 parent 5b1b9fb commit 3f54198

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

text_extensions_for_pandas/array/tensor.py

+5
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ def astype(self, dtype, copy=True):
482482
return dtype.construct_array_type()._from_sequence(values, copy=False)
483483
else:
484484
return values
485+
elif pd.api.types.is_object_dtype(dtype):
486+
# Interpret astype(object) as "cast to an array of numpy arrays"
487+
values = np.empty(len(self), dtype=object)
488+
for i in range(len(self)):
489+
values[i] = self._tensor[i]
485490
else:
486491
values = self._tensor.astype(dtype, copy=copy)
487492
return values

0 commit comments

Comments
 (0)