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

Class BlockwiseHead

dask/dataframe/dask_expr/_expr.py:2613–2641  ·  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

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

Callers 1

_lowerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected