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

Method to_dask_array

dask/dataframe/dask_expr/_collection.py:1389–1428  ·  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

1387 )
1388
1389 def to_dask_array(
1390 self, lengths=None, meta=None, optimize: bool = True, **optimize_kwargs
1391 ) -> Array:
1392 """Convert a dask DataFrame to a dask array.
1393
1394 Parameters
1395 ----------
1396 lengths : bool or Sequence of ints, optional
1397 How to determine the chunks sizes for the output array.
1398 By default, the output array will have unknown chunk lengths
1399 along the first axis, which can cause some later operations
1400 to fail.
1401
1402 * True : immediately compute the length of each partition
1403 * Sequence : a sequence of integers to use for the chunk sizes
1404 on the first axis. These values are *not* validated for
1405 correctness, beyond ensuring that the number of items
1406 matches the number of partitions.
1407 meta : object, optional
1408 An optional `meta` parameter can be passed for dask to override the
1409 default metadata on the underlying dask array.
1410 optimize : bool
1411 Whether to optimize the expression before converting to an Array.
1412
1413 Returns
1414 -------
1415 A Dask Array
1416 """
1417 if lengths is True:
1418 lengths = tuple(self.map_partitions(len).compute())
1419
1420 arr = self.values
1421
1422 chunks = self._validate_chunks(arr, lengths)
1423 arr._chunks = chunks
1424
1425 if meta is not None:
1426 arr._meta = meta
1427
1428 return arr
1429
1430 @property
1431 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