MCPcopy Create free account
hub / github.com/dask/dask / to_dask_array

Method to_dask_array

dask/dataframe/dask_expr/_collection.py:1425–1464  ·  view source on GitHub ↗

Convert a dask DataFrame to a dask array. Parameters ---------- lengths : bool or Sequence of ints, optional How to determine the chunks sizes for the output array. By default, the output array will have unknown chunk lengths along the fir

(
        self, lengths=None, meta=None, optimize: bool = True, **optimize_kwargs
    )

Source from the content-addressed store, hash-verified

1423 )
1424
1425 def to_dask_array(
1426 self, lengths=None, meta=None, optimize: bool = True, **optimize_kwargs
1427 ) -> Array:
1428 """Convert a dask DataFrame to a dask array.
1429
1430 Parameters
1431 ----------
1432 lengths : bool or Sequence of ints, optional
1433 How to determine the chunks sizes for the output array.
1434 By default, the output array will have unknown chunk lengths
1435 along the first axis, which can cause some later operations
1436 to fail.
1437
1438 * True : immediately compute the length of each partition
1439 * Sequence : a sequence of integers to use for the chunk sizes
1440 on the first axis. These values are *not* validated for
1441 correctness, beyond ensuring that the number of items
1442 matches the number of partitions.
1443 meta : object, optional
1444 An optional `meta` parameter can be passed for dask to override the
1445 default metadata on the underlying dask array.
1446 optimize : bool
1447 Whether to optimize the expression before converting to an Array.
1448
1449 Returns
1450 -------
1451 A Dask Array
1452 """
1453 if lengths is True:
1454 lengths = tuple(self.map_partitions(len).compute())
1455
1456 arr = self.values
1457
1458 chunks = self._validate_chunks(arr, lengths)
1459 arr._chunks = chunks
1460
1461 if meta is not None:
1462 arr._meta = meta
1463
1464 return arr
1465
1466 @property
1467 def values(self):

Callers 13

to_numericFunction · 0.80
test_to_dask_arrayFunction · 0.80
test_to_numericFunction · 0.80
test_to_dask_arrayFunction · 0.80
asarrayFunction · 0.80
asanyarrayFunction · 0.80
asarrayFunction · 0.80

Calls 3

map_partitionsMethod · 0.95
_validate_chunksMethod · 0.95
computeMethod · 0.45

Tested by 8

test_to_dask_arrayFunction · 0.64
test_to_numericFunction · 0.64
test_to_dask_arrayFunction · 0.64