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

Class ValueCounts

dask/dataframe/dask_expr/_reductions.py:1403–1472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

_lowerMethod · 0.90
value_countsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected