Struct polars::datatypes::Field

source ·
pub struct Field {
    pub name: SmartString<LazyCompact>,
    pub dtype: DataType,
}
Expand description

Characterizes the name and the DataType of a column.

Fields§

§name: SmartString<LazyCompact>§dtype: DataType

Implementations§

source§

impl Field

source

pub fn new(name: &str, dtype: DataType) -> Field

Creates a new Field.

§Example
let f1 = Field::new("Fruit name", DataType::String);
let f2 = Field::new("Lawful", DataType::Boolean);
let f2 = Field::new("Departure", DataType::Time);
source

pub fn from_owned(name: SmartString<LazyCompact>, dtype: DataType) -> Field

source

pub fn name(&self) -> &SmartString<LazyCompact>

Returns a reference to the Field name.

§Example
let f = Field::new("Year", DataType::Int32);

assert_eq!(f.name(), "Year");
source

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);
source

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));
source

pub fn set_name(&mut self, name: SmartString<LazyCompact>)

Sets the Field name.

§Example
let mut f = Field::new("Atomic number", DataType::UInt32);
f.set_name("Proton".into());

assert_eq!(f, Field::new("Proton", DataType::UInt32));
source

pub fn to_arrow(&self, pl_flavor: bool) -> Field

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::ArrowDataType::Int64, true);

assert_eq!(f.to_arrow(true), af);

Trait Implementations§

source§

impl Clone for Field

source§

fn clone(&self) -> Field

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Field

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'a> From<&AnyValue<'a>> for Field

source§

fn from(val: &AnyValue<'a>) -> Field

Converts to this type from the input type.
source§

impl From<&Field> for Field

source§

fn from(f: &Field) -> Field

Converts to this type from the input type.
source§

impl PartialEq for Field

source§

fn eq(&self, other: &Field) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Field

source§

impl StructuralPartialEq for Field

Auto Trait Implementations§

§

impl Freeze for Field

§

impl !RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl !UnwindSafe for Field

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V