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

Class Scalar

dask/dataframe/dask_expr/_collection.py:4867–4898  ·  view source on GitHub ↗

Scalar Expr Collection

Source from the content-addressed store, hash-verified

4865
4866
4867class Scalar(FrameBase):
4868 """Scalar Expr Collection"""
4869
4870 def __repr__(self):
4871 return f"<dask_expr.expr.Scalar: expr={self.expr}, dtype={self.dtype}>"
4872
4873 def __bool__(self):
4874 raise TypeError(
4875 f"Trying to convert {self} to a boolean value. Because Dask objects are "
4876 "lazily evaluated, they cannot be converted to a boolean value or used "
4877 "in boolean conditions like if statements. Try calling .compute() to "
4878 "force computation prior to converting to a boolean value or using in "
4879 "a conditional statement."
4880 )
4881
4882 def __dask_postcompute__(self):
4883 return first, ()
4884
4885 def to_series(self, index=0) -> Series:
4886 return new_collection(expr.ScalarToSeries(self, index=index))
4887
4888 def __array__(self):
4889 # array interface is required to support pandas instance + Scalar
4890 # Otherwise, above op results in pd.Series of Scalar (object dtype)
4891 return np.asarray(self.compute())
4892
4893 @functools.cached_property
4894 def dtype(self):
4895 return pd.Series(self._meta).dtype
4896
4897 def to_delayed(self, optimize_graph=True):
4898 return super().to_delayed(optimize_graph=optimize_graph)[0]
4899
4900
4901def optimize(collection, fuse=True):

Callers 1

create_scalar_collectionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected