Struct polars_core::datatypes::Field
source · [−]Expand description
Characterizes the name and the DataType
of a column.
Fields
name: String
dtype: DataType
Implementations
sourceimpl Field
impl Field
sourcepub fn new(name: &str, dtype: DataType) -> Self
pub fn new(name: &str, dtype: DataType) -> Self
Creates a new Field
.
Example
let f1 = Field::new("Fruit name", DataType::Utf8);
let f2 = Field::new("Lawful", DataType::Boolean);
let f2 = Field::new("Departure", DataType::Time);
pub fn from_owned(name: String, dtype: DataType) -> Self
sourcepub fn name(&self) -> &String
pub fn name(&self) -> &String
Returns a reference to the Field
name.
Example
let f = Field::new("Year", DataType::Int32);
assert_eq!(f.name(), "Year");
sourcepub fn data_type(&self) -> &DataType
pub fn data_type(&self) -> &DataType
Returns a reference to the Field
datatype.
Example
let f = Field::new("Birthday", DataType::Date);
assert_eq!(f.data_type(), &DataType::Date);
sourcepub fn coerce(&mut self, dtype: DataType)
pub fn coerce(&mut self, dtype: DataType)
Sets the Field
datatype.
Example
let mut f = Field::new("Temperature", DataType::Int32);
f.coerce(DataType::Float32);
assert_eq!(f, Field::new("Temperature", DataType::Float32));
sourcepub fn set_name(&mut self, name: String)
pub fn set_name(&mut self, name: String)
Sets the Field
name.
Example
let mut f = Field::new("Atomic number", DataType::UInt32);
f.set_name("Proton".to_owned());
assert_eq!(f, Field::new("Proton", DataType::UInt32));
sourcepub fn to_arrow(&self) -> ArrowField
pub fn to_arrow(&self) -> ArrowField
Converts the Field
to an arrow::datatypes::Field
.
Example
let f = Field::new("Value", DataType::Int64);
let af = arrow::datatypes::Field::new("Value", arrow::datatypes::DataType::Int64, true);
assert_eq!(f.to_arrow(), af);
Trait Implementations
sourceimpl From<&Field> for Field
impl From<&Field> for Field
sourcefn from(f: &ArrowField) -> Self
fn from(f: &ArrowField) -> Self
Converts to this type from the input type.
impl Eq for Field
impl StructuralEq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.