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