MCPcopy
hub / github.com/dask/dask / to_dask_array

Method to_dask_array

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

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