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

Class Scalar

dask/dataframe/dask_expr/_collection.py:4792–4823  ·  view source on GitHub ↗

Scalar Expr Collection

Source from the content-addressed store, hash-verified

4790
4791
4792class Scalar(FrameBase):
4793 """Scalar Expr Collection"""
4794
4795 def __repr__(self):
4796 return f"<dask_expr.expr.Scalar: expr={self.expr}, dtype={self.dtype}>"
4797
4798 def __bool__(self):
4799 raise TypeError(
4800 f"Trying to convert {self} to a boolean value. Because Dask objects are "
4801 "lazily evaluated, they cannot be converted to a boolean value or used "
4802 "in boolean conditions like if statements. Try calling .compute() to "
4803 "force computation prior to converting to a boolean value or using in "
4804 "a conditional statement."
4805 )
4806
4807 def __dask_postcompute__(self):
4808 return first, ()
4809
4810 def to_series(self, index=0) -> Series:
4811 return new_collection(expr.ScalarToSeries(self, index=index))
4812
4813 def __array__(self):
4814 # array interface is required to support pandas instance + Scalar
4815 # Otherwise, above op results in pd.Series of Scalar (object dtype)
4816 return np.asarray(self.compute())
4817
4818 @functools.cached_property
4819 def dtype(self):
4820 return pd.Series(self._meta).dtype
4821
4822 def to_delayed(self, optimize_graph=True):
4823 return super().to_delayed(optimize_graph=optimize_graph)[0]
4824
4825
4826def optimize(collection, fuse=True):

Callers 1

create_scalar_collectionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected