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

Method to_dask_array

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

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