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

Method repartition

dask/dataframe/dask_expr/_collection.py:1328–1423  ·  view source on GitHub ↗

Repartition a collection Exactly one of `divisions`, `npartitions` or `partition_size` should be specified. A ``ValueError`` will be raised when that is not the case. Parameters ---------- divisions : list, optional The "dividing lines" used to s

(
        self,
        divisions: tuple | None = None,
        npartitions: int | None = None,
        partition_size: str | None = None,
        freq=None,
        force: bool = False,
    )

Source from the content-addressed store, hash-verified

1326 )
1327
1328 def repartition(
1329 self,
1330 divisions: tuple | None = None,
1331 npartitions: int | None = None,
1332 partition_size: str | None = None,
1333 freq=None,
1334 force: bool = False,
1335 ):
1336 """Repartition a collection
1337
1338 Exactly one of `divisions`, `npartitions` or `partition_size` should be
1339 specified. A ``ValueError`` will be raised when that is not the case.
1340
1341 Parameters
1342 ----------
1343 divisions : list, optional
1344 The "dividing lines" used to split the dataframe into partitions.
1345 For ``divisions=[0, 10, 50, 100]``, there would be three output partitions,
1346 where the new index contained [0, 10), [10, 50), and [50, 100), respectively.
1347 See https://docs.dask.org/en/latest/dataframe-design.html#partitions.
1348 npartitions : int | Callable, optional
1349 Approximate number of partitions of output. The number of
1350 partitions used may be slightly lower than npartitions depending
1351 on data distribution, but will never be higher.
1352 The Callable gets the number of partitions of the input as an argument
1353 and should return an int.
1354 partition_size : str, optional
1355 Max number of bytes of memory for each partition. Use numbers or strings
1356 like 5MB. If specified npartitions and divisions will be ignored. Note that
1357 the size reflects the number of bytes used as computed by
1358 pandas.DataFrame.memory_usage, which will not necessarily match the size
1359 when storing to disk.
1360
1361 .. warning::
1362
1363 This keyword argument triggers computation to determine
1364 the memory size of each partition, which may be expensive.
1365
1366 force : bool, default False
1367 Allows the expansion of the existing divisions.
1368 If False then the new divisions' lower and upper bounds must be
1369 the same as the old divisions'.
1370 freq : str, pd.Timedelta
1371 A period on which to partition timeseries data like ``'7D'`` or
1372 ``'12h'`` or ``pd.Timedelta(hours=12)``. Assumes a datetime index.
1373
1374 Notes
1375 -----
1376 Exactly one of `divisions`, `npartitions`, `partition_size`, or `freq`
1377 should be specified. A ``ValueError`` will be raised when that is
1378 not the case.
1379
1380 Also note that ``len(divisions)`` is equal to ``npartitions + 1``. This is because ``divisions``
1381 represents the upper and lower bounds of each partition. The first item is the
1382 lower bound of the first partition, the second item is the lower bound of the
1383 second partition and the upper bound of the first partition, and so on.
1384 The second-to-last item is the lower bound of the last partition, and the last
1385 (extra) item is the upper bound of the last partition.

Callers 15

medianMethod · 0.45
analyzeMethod · 0.45
explainMethod · 0.45
repartitionFunction · 0.45
test_io_fusion_blockwiseFunction · 0.45
test_shuffleFunction · 0.45
test_empty_partitionsFunction · 0.45

Calls 5

check_divisionsFunction · 0.90
new_collectionFunction · 0.90
RepartitionFreqClass · 0.90
RepartitionClass · 0.90
sumFunction · 0.50