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

Class ValueCounts

dask/dataframe/dask_expr/_reductions.py:1405–1474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1403
1404
1405class ValueCounts(ReductionConstantDim):
1406 _defaults = {
1407 "sort": None,
1408 "ascending": False,
1409 "dropna": True,
1410 "normalize": False,
1411 "split_every": None,
1412 "split_out": 1,
1413 "total_length": None,
1414 }
1415
1416 _parameters = [
1417 "frame",
1418 "sort",
1419 "ascending",
1420 "dropna",
1421 "normalize",
1422 "split_every",
1423 "split_out",
1424 "total_length",
1425 ]
1426 reduction_chunk = M.value_counts
1427 reduction_aggregate = methods.value_counts_aggregate
1428 reduction_combine = methods.value_counts_combine
1429 split_by = None
1430
1431 @functools.cached_property
1432 def _meta(self):
1433 return self.frame._meta.value_counts(normalize=self.normalize)
1434
1435 @classmethod
1436 def aggregate(cls, inputs, **kwargs):
1437 func = cls.reduction_aggregate or cls.reduction_chunk
1438 if is_scalar(inputs[-1]):
1439 return func(_concat(inputs[:-1]), inputs[-1], observed=True, **kwargs)
1440 else:
1441 return func(_concat(inputs), observed=True, **kwargs)
1442
1443 @property
1444 def shuffle_by_index(self):
1445 return True
1446
1447 @property
1448 def chunk_kwargs(self):
1449 return {"sort": self.sort, "ascending": self.ascending, "dropna": self.dropna}
1450
1451 @property
1452 def aggregate_args(self):
1453 if self.normalize and (self.split_out > 1 or self.split_out is True):
1454 return [self.total_length]
1455 return []
1456
1457 @property
1458 def aggregate_kwargs(self):
1459 return {**self.chunk_kwargs, "normalize": self.normalize}
1460
1461 @property
1462 def combine_kwargs(self):

Callers 2

_lowerMethod · 0.90
value_countsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected