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

Class BlockwiseHead

dask/dataframe/dask_expr/_expr.py:2609–2637  ·  view source on GitHub ↗

Take the first `n` rows of every partition Typically used after `Partitions(..., [0])` to take the first `n` rows of an entire collection.

Source from the content-addressed store, hash-verified

2607
2608
2609class BlockwiseHead(Head, Blockwise):
2610 """Take the first `n` rows of every partition
2611
2612 Typically used after `Partitions(..., [0])` to take
2613 the first `n` rows of an entire collection.
2614 """
2615
2616 _parameters = ["frame", "n", "npartitions", "safe"]
2617 _preserves_partitioning_information = True
2618
2619 def _simplify_down(self):
2620 return
2621
2622 def _simplify_up(self, parent, dependents):
2623 return
2624
2625 @functools.cached_property
2626 def npartitions(self):
2627 return len(self._divisions()) - 1
2628
2629 def _divisions(self):
2630 return self.frame.divisions[: len(self._partitions) + 1]
2631
2632 def _task(self, name: Key, index: int) -> Task:
2633 if self.safe:
2634 op = safe_head
2635 else:
2636 op = M.head
2637 return Task(name, op, TaskRef((self.frame._name, index)), self.n)
2638
2639
2640class BlockwiseHeadIndex(BlockwiseHead):

Callers 1

_lowerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected