Scalar#

class pylibcudf.scalar.Scalar(*args, **kwargs)#

A scalar value in device memory.

This is the Cython representation of cudf::scalar.

Methods

from_arrow(pa_val, DataType dtype)

Convert a pyarrow scalar to a pylibcudf.Scalar.

from_numpy(cls, np_val)

Convert a NumPy scalar to a Scalar.

from_py(cls, py_val, DataType dtype)

Convert a Python standard library object to a Scalar.

is_valid(self)

True if the scalar is valid, false if not

to_py(self)

Convert a Scalar to a Python scalar.

type(self)

The type of data in the column.

static from_arrow(pa_val, DataType dtype: DataType | None = None) Scalar#

Convert a pyarrow scalar to a pylibcudf.Scalar.

Parameters:
pa_val: pyarrow scalar

Value to convert to a pylibcudf.Scalar

dtype: DataType | None

The datatype to cast the value to. If None, the type is inferred from the pyarrow scalar.

Returns:
Scalar

New pylibcudf.Scalar

classmethod from_numpy(cls, np_val)#

Convert a NumPy scalar to a Scalar.

Parameters:
np_val: numpy.generic

Value to convert to a pylibcudf.Scalar

Returns:
Scalar

New pylibcudf.Scalar

classmethod from_py(cls, py_val, DataType dtype: DataType | None = None)#

Convert a Python standard library object to a Scalar.

Parameters:
py_val: None, bool, int, float, str, datetime, timedelta, list, dict

Value to convert to a pylibcudf.Scalar

dtype: DataType | None

The datatype to cast the value to. If None, the type is inferred from py_val.

Returns:
Scalar

New pylibcudf.Scalar

is_valid(self) bool#

True if the scalar is valid, false if not

to_py(self)#

Convert a Scalar to a Python scalar.

Returns:
Python scalar

A Python scalar associated with the type of the Scalar.

type(self) DataType#

The type of data in the column.