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
)
| 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): |