Skip to content

Commit 86baa9f

Browse files
authored
BUG: Series(dask.array) GH#38645 (#42577)
1 parent fa8ccbf commit 86baa9f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

doc/source/whatsnew/v1.3.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Fixed regressions
2424
- Fixed regression in indexing with a ``list`` subclass incorrectly raising ``TypeError`` (:issue:`42433`, :issue:`42461`)
2525
- Fixed regression in :meth:`DataFrame.isin` and :meth:`Series.isin` raising ``TypeError`` with nullable data containing at least one missing value (:issue:`42405`)
2626
- Regression in :func:`concat` between objects with bool dtype and integer dtype casting to object instead of to integer (:issue:`42092`)
27+
- Bug in :class:`Series` constructor not accepting a ``dask.Array`` (:issue:`38645`)
2728

2829
.. ---------------------------------------------------------------------------
2930

pandas/core/construction.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,11 @@ def sanitize_array(
560560
raise TypeError(f"'{type(data).__name__}' type is unordered")
561561

562562
# materialize e.g. generators, convert e.g. tuples, abc.ValueView
563-
# TODO: non-standard array-likes we can convert to ndarray more efficiently?
564-
data = list(data)
563+
if hasattr(data, "__array__"):
564+
# e.g. dask array GH#38645
565+
data = np.asarray(data)
566+
else:
567+
data = list(data)
565568

566569
if dtype is not None or len(data) == 0:
567570
subarr = _try_cast(data, dtype, copy, raise_cast_failure)

0 commit comments

Comments
 (0)