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

Class CustomReduction

dask/dataframe/dask_expr/_reductions.py:846–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

844
845
846class CustomReduction(Reduction):
847 _parameters = [
848 "frame",
849 "meta",
850 "chunk_kwargs",
851 "aggregate_kwargs",
852 "combine_kwargs",
853 "split_every",
854 "token",
855 ]
856
857 @functools.cached_property
858 def _name(self):
859 name = self.operand("token") or funcname(type(self)).lower()
860 return name + "-" + self.deterministic_token
861
862 @classmethod
863 def chunk(cls, df, **kwargs):
864 func = kwargs.pop("func")
865 out = func(df, **kwargs)
866 # Return a dataframe so that the concatenated version is also a dataframe
867 return out.to_frame().T if is_series_like(out) else out
868
869 @classmethod
870 def combine(cls, inputs: list, **kwargs): # type: ignore
871 func = kwargs.pop("func")
872 df = _concat(inputs)
873 out = func(df, **kwargs)
874 # Return a dataframe so that the concatenated version is also a dataframe
875 return out.to_frame().T if is_series_like(out) else out
876
877 @classmethod
878 def aggregate(cls, inputs, **kwargs):
879 func = kwargs.pop("func")
880 df = _concat(inputs)
881 return func(df, **kwargs)
882
883 @functools.cached_property
884 def _meta(self):
885 if self.operand("meta") is not no_default:
886 return self.operand("meta")
887 return super()._meta
888
889 @property
890 def chunk_kwargs(self):
891 return self.operand("chunk_kwargs")
892
893 @property
894 def combine_kwargs(self):
895 return self.operand("combine_kwargs")
896
897 @property
898 def aggregate_kwargs(self):
899 return self.operand("aggregate_kwargs")
900
901 def _simplify_up(self, parent, dependents):
902 return
903

Callers 1

reductionMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected