Module cast
Expand description
Cast kernels to convert ArrayRef between supported datatypes.
See cast_with_options for more information on specific conversions.
Example:
// int32 to float64
let a = Int32Array::from(vec![5, 6, 7]);
let b = cast(&a, &DataType::Float64).unwrap();
let c = b.as_primitive::<Float64Type>();
assert_eq!(5.0, c.value(0));
assert_eq!(6.0, c.value(1));
assert_eq!(7.0, c.value(2));Structs§
- Cast
Options - CastOptions provides a way to override the default cast behaviors
Traits§
- Decimal
Cast - A utility trait that provides checked conversions between
decimal types inspired by
NumCast
Functions§
- can_
cast_ types - Return true if a value of type
from_typecan be cast into a value ofto_type. - cast
- Cast
arrayto the provided data type and return a new Array with typeto_type, if possible. - cast_
num_ to_ bool - Cast numeric types to boolean
- cast_
single_ string_ to_ boolean_ default - Cast a single string to boolean with default cast option(safe=true).
- cast_
with_ options - Try to cast
arraytoto_typeif possible. - num_
cast - Natural cast between numeric types
Return None if the input
valuecan’t be casted to typeO. - rescale_
decimal - Rescales a decimal value from
(input_precision, input_scale)to(output_precision, output_scale)and returns the converted number when it fits within the output precision. - single_
bool_ to_ numeric - Cast single bool value to numeric value.
- union_
extract_ by_ type - Extracts the best-matching child array from a
UnionArrayfor a given target type, and casts it to that type.