Struct polars_core::datatypes::Field
source · [−]pub struct Field { /* private fields */ }
Expand description
Characterizes the name and the DataType
of a column.
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
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more