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

Class CustomReduction

dask/dataframe/dask_expr/_reductions.py:844–903  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

reductionMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected