pub enum Scalar {
Null(NullKind),
Bool(bool),
Int64(i64),
Float64(f64),
Utf8(String),
Timedelta64(i64),
Datetime64(i64),
Period(Period),
Interval(Interval),
Object(ObjectValue),
}Variants§
Null(NullKind)
Bool(bool)
Int64(i64)
Float64(f64)
Utf8(String)
Timedelta64(i64)
Datetime64(i64)
Nanoseconds since Unix epoch. Matches pandas datetime64[ns].
Uses Timestamp::NAT (i64::MIN) for missing values.
Period(Period)
Period value (ordinal + frequency). A Period whose ordinal is
i64::MIN is NaT (missing). The frequency is carried so writers can
render the pandas calendar string (2024Q1, 2024-03, …) — the
calendar string is not recoverable from the ordinal alone, since
different frequencies share overlapping ordinal axes.
Interval(Interval)
Numeric interval value. Missing values remain Scalar::Null.
Object(ObjectValue)
A pandas object cell none of the kinds above holds: a list
(str.split’s cells, Series([[1, 2], [3]])) or a host-language
value the core only carries (fvsao.33).
Implementations§
Source§impl Scalar
impl Scalar
Sourcepub fn python_cmp(&self, other: &Self) -> Option<Ordering>
pub fn python_cmp(&self, other: &Self) -> Option<Ordering>
Python’s ordering of two values: numbers by value, text by code
point, instants, durations and same-frequency periods by their
payload, intervals by (left, right), object cells by
ObjectValue::python_cmp; None where
Python raises (a number against text, a list against a tuple, two
dicts).
Sourcepub fn python_cmp_type_names(&self, other: &Self) -> (String, String)
pub fn python_cmp_type_names(&self, other: &Self) -> (String, String)
The two types Python’s TypeError names when it cannot order self
against other (see Self::python_cmp): two lists by the first
unequal items they hold ([1] < ['a'] names ‘int’ and ‘str’), any
other pair by their own types.
Sourcepub fn python_type_name(&self) -> String
pub fn python_type_name(&self) -> String
The value’s Python type as Python’s errors name it (str, int,
Timestamp, list), for a TypeError pandas lets Python raise.
Sourcepub fn python_repr(&self) -> String
pub fn python_repr(&self) -> String
The value as Python’s repr spells it inside a container ('a',
1, 1.5, None, nan, [1, 2]) - how a list cell prints its
items.
Source§impl Scalar
impl Scalar
pub fn dtype(&self) -> DType
pub fn is_missing(&self) -> bool
pub fn is_nan(&self) -> bool
Sourcepub const fn is_integer(&self) -> bool
pub const fn is_integer(&self) -> bool
Returns true if this is an Int64 scalar.
Sourcepub const fn is_numeric(&self) -> bool
pub const fn is_numeric(&self) -> bool
Returns true if this is a numeric scalar (Int64 or Float64).
Sourcepub const fn is_datetime(&self) -> bool
pub const fn is_datetime(&self) -> bool
Returns true if this is a Datetime64 scalar.
Sourcepub const fn is_timedelta(&self) -> bool
pub const fn is_timedelta(&self) -> bool
Returns true if this is a Timedelta64 scalar.
Sourcepub const fn is_interval(&self) -> bool
pub const fn is_interval(&self) -> bool
Returns true if this is an Interval scalar.
Sourcepub const fn as_i64(&self) -> Option<i64>
pub const fn as_i64(&self) -> Option<i64>
Returns the wrapped i64 if this is an Scalar::Int64 variant.
Sourcepub const fn as_int(&self) -> Option<i64>
pub const fn as_int(&self) -> Option<i64>
Alias for Scalar::as_i64.
Sourcepub const fn as_f64(&self) -> Option<f64>
pub const fn as_f64(&self) -> Option<f64>
Returns the wrapped f64 if this is a Scalar::Float64 variant.
Sourcepub const fn as_float(&self) -> Option<f64>
pub const fn as_float(&self) -> Option<f64>
Alias for Scalar::as_f64.
Sourcepub const fn as_bool(&self) -> Option<bool>
pub const fn as_bool(&self) -> Option<bool>
Returns the wrapped bool if this is a Scalar::Bool variant.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a string slice if this is a Scalar::Utf8 variant.
Sourcepub const fn as_datetime_nanos(&self) -> Option<i64>
pub const fn as_datetime_nanos(&self) -> Option<i64>
Returns the raw nanoseconds timestamp if this is a Scalar::Datetime64 variant.
Sourcepub const fn as_timedelta_nanos(&self) -> Option<i64>
pub const fn as_timedelta_nanos(&self) -> Option<i64>
Returns the raw nanoseconds duration if this is a Scalar::Timedelta64 variant.
Sourcepub const fn as_period_ordinal(&self) -> Option<i64>
pub const fn as_period_ordinal(&self) -> Option<i64>
Returns the period ordinal if this is a Scalar::Period variant.
Sourcepub const fn as_interval(&self) -> Option<Interval>
pub const fn as_interval(&self) -> Option<Interval>
Returns the Interval if this is a Scalar::Interval variant.
pub fn missing_for_dtype(dtype: DType) -> Self
pub fn semantic_eq(&self, other: &Self) -> bool
pub fn semantic_le(&self, other: &Self) -> bool
pub fn semantic_ge(&self, other: &Self) -> bool
pub fn is_null(&self) -> bool
pub fn is_na(&self) -> bool
Sourcepub fn isna(&self) -> bool
pub fn isna(&self) -> bool
Return true if this scalar is NA/missing (alias for Self::is_na).
Sourcepub fn isnull(&self) -> bool
pub fn isnull(&self) -> bool
Return true if this scalar is null (alias for Self::is_null).
Sourcepub fn notna(&self) -> bool
pub fn notna(&self) -> bool
Return true if this scalar is not NA/missing (matches pandas notna).
Sourcepub fn notnull(&self) -> bool
pub fn notnull(&self) -> bool
Return true if this scalar is not null/missing (matches pandas notnull).
pub fn coalesce(&self, other: &Self) -> Self
pub fn semantic_cmp(&self, other: &Self) -> Ordering
pub fn to_f64(&self) -> Result<f64, TypeError>
Sourcepub fn to_i64(&self) -> Result<i64, TypeError>
pub fn to_i64(&self) -> Result<i64, TypeError>
Try to convert to i64. Returns error for missing or non-numeric values.