pub enum Column {
Series(SeriesColumn),
Partitioned(PartitionedColumn),
Scalar(ScalarColumn),
}
Expand description
A column within a DataFrame
.
This is lazily initialized to a Series
with methods like
as_materialized_series
and
take_materialized_series
.
Currently, there are two ways to represent a Column
.
- A
Series
of values - A
ScalarColumn
that repeats a singleScalar
Variants§
Implementations§
Source§impl Column
impl Column
pub fn new<T, Phantom>(name: PlSmallStr, values: T) -> Self
pub fn new_empty(name: PlSmallStr, dtype: &DataType) -> Self
pub fn new_scalar(name: PlSmallStr, scalar: Scalar, length: usize) -> Self
pub fn new_partitioned(name: PlSmallStr, scalar: Scalar, length: usize) -> Self
Sourcepub fn as_materialized_series(&self) -> &Series
pub fn as_materialized_series(&self) -> &Series
Sourcepub fn into_materialized_series(&mut self) -> &mut Series
pub fn into_materialized_series(&mut self) -> &mut Series
Turn Column
into a Column::Series
.
This may need to materialize the Series
on the first invocation for a specific column.
Sourcepub fn take_materialized_series(self) -> Series
pub fn take_materialized_series(self) -> Series
pub fn dtype(&self) -> &DataType
pub fn field(&self) -> Cow<'_, Field>
pub fn name(&self) -> &PlSmallStr
pub fn len(&self) -> usize
pub fn with_name(self, name: PlSmallStr) -> Column
pub fn rename(&mut self, name: PlSmallStr)
pub fn as_series(&self) -> Option<&Series>
pub fn as_partitioned_column(&self) -> Option<&PartitionedColumn>
pub fn as_scalar_column(&self) -> Option<&ScalarColumn>
pub fn try_bool(&self) -> Option<&BooleanChunked>
pub fn try_i8(&self) -> Option<&Int8Chunked>
pub fn try_i16(&self) -> Option<&Int16Chunked>
pub fn try_i32(&self) -> Option<&Int32Chunked>
pub fn try_i64(&self) -> Option<&Int64Chunked>
pub fn try_u8(&self) -> Option<&UInt8Chunked>
pub fn try_u16(&self) -> Option<&UInt16Chunked>
pub fn try_u32(&self) -> Option<&UInt32Chunked>
pub fn try_u64(&self) -> Option<&UInt64Chunked>
pub fn try_f32(&self) -> Option<&Float32Chunked>
pub fn try_f64(&self) -> Option<&Float64Chunked>
pub fn try_str(&self) -> Option<&StringChunked>
pub fn try_list(&self) -> Option<&ListChunked>
pub fn try_binary(&self) -> Option<&BinaryChunked>
pub fn try_idx(&self) -> Option<&IdxCa>
pub fn try_binary_offset(&self) -> Option<&BinaryOffsetChunked>
pub fn try_decimal(&self) -> Option<&DecimalChunked>
dtype-decimal
only.pub fn try_array(&self) -> Option<&ArrayChunked>
dtype-array
only.pub fn try_categorical(&self) -> Option<&CategoricalChunked>
dtype-categorical
only.pub fn bool(&self) -> PolarsResult<&BooleanChunked>
pub fn i8(&self) -> PolarsResult<&Int8Chunked>
pub fn i16(&self) -> PolarsResult<&Int16Chunked>
pub fn i32(&self) -> PolarsResult<&Int32Chunked>
pub fn i64(&self) -> PolarsResult<&Int64Chunked>
pub fn i128(&self) -> PolarsResult<&Int128Chunked>
dtype-i128
only.pub fn u8(&self) -> PolarsResult<&UInt8Chunked>
pub fn u16(&self) -> PolarsResult<&UInt16Chunked>
pub fn u32(&self) -> PolarsResult<&UInt32Chunked>
pub fn u64(&self) -> PolarsResult<&UInt64Chunked>
pub fn f32(&self) -> PolarsResult<&Float32Chunked>
pub fn f64(&self) -> PolarsResult<&Float64Chunked>
pub fn str(&self) -> PolarsResult<&StringChunked>
pub fn list(&self) -> PolarsResult<&ListChunked>
pub fn binary(&self) -> PolarsResult<&BinaryChunked>
pub fn idx(&self) -> PolarsResult<&IdxCa>
pub fn binary_offset(&self) -> PolarsResult<&BinaryOffsetChunked>
pub fn decimal(&self) -> PolarsResult<&DecimalChunked>
dtype-decimal
only.pub fn array(&self) -> PolarsResult<&ArrayChunked>
dtype-array
only.pub fn categorical(&self) -> PolarsResult<&CategoricalChunked>
dtype-categorical
only.pub fn cast_with_options( &self, dtype: &DataType, options: CastOptions, ) -> PolarsResult<Self>
pub fn strict_cast(&self, dtype: &DataType) -> PolarsResult<Self>
pub fn cast(&self, dtype: &DataType) -> PolarsResult<Column>
Sourcepub unsafe fn cast_unchecked(&self, dtype: &DataType) -> PolarsResult<Column>
pub unsafe fn cast_unchecked(&self, dtype: &DataType) -> PolarsResult<Column>
§Safety
This can lead to invalid memory access in downstream code.
pub fn clear(&self) -> Self
pub fn shrink_to_fit(&mut self)
pub fn new_from_index(&self, index: usize, length: usize) -> Self
pub fn has_nulls(&self) -> bool
pub fn is_null(&self) -> BooleanChunked
pub fn is_not_null(&self) -> BooleanChunked
pub fn to_physical_repr(&self) -> Column
Sourcepub unsafe fn from_physical_unchecked(
&self,
dtype: &DataType,
) -> PolarsResult<Column>
pub unsafe fn from_physical_unchecked( &self, dtype: &DataType, ) -> PolarsResult<Column>
§Safety
This can lead to invalid memory access in downstream code.
pub fn head(&self, length: Option<usize>) -> Column
pub fn tail(&self, length: Option<usize>) -> Column
pub fn slice(&self, offset: i64, length: usize) -> Column
pub fn split_at(&self, offset: i64) -> (Column, Column)
pub fn null_count(&self) -> usize
pub fn take(&self, indices: &IdxCa) -> PolarsResult<Column>
pub fn take_slice(&self, indices: &[IdxSize]) -> PolarsResult<Column>
Sourcepub unsafe fn take_unchecked(&self, indices: &IdxCa) -> Column
pub unsafe fn take_unchecked(&self, indices: &IdxCa) -> Column
§Safety
No bounds on the indexes are performed.
Sourcepub unsafe fn take_slice_unchecked(&self, indices: &[IdxSize]) -> Column
pub unsafe fn take_slice_unchecked(&self, indices: &[IdxSize]) -> Column
§Safety
No bounds on the indexes are performed.
Sourcepub unsafe fn agg_min(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_min(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_max(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_max(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_mean(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_mean(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_sum(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_sum(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_first(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_first(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_last(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_last(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_n_unique(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_n_unique(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_quantile(
&self,
groups: &GroupsProxy,
quantile: f64,
method: QuantileMethod,
) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_quantile( &self, groups: &GroupsProxy, quantile: f64, method: QuantileMethod, ) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_median(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_median(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_var(&self, groups: &GroupsProxy, ddof: u8) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_var(&self, groups: &GroupsProxy, ddof: u8) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_std(&self, groups: &GroupsProxy, ddof: u8) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_std(&self, groups: &GroupsProxy, ddof: u8) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub unsafe fn agg_list(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub unsafe fn agg_list(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
Sourcepub fn agg_valid_count(&self, groups: &GroupsProxy) -> Self
Available on crate feature algorithm_group_by
only.
pub fn agg_valid_count(&self, groups: &GroupsProxy) -> Self
algorithm_group_by
only.§Safety
Does no bounds checks, groups must be correct.
pub fn full_null(name: PlSmallStr, size: usize, dtype: &DataType) -> Self
pub fn is_empty(&self) -> bool
pub fn reverse(&self) -> Column
pub fn equals(&self, other: &Column) -> bool
pub fn equals_missing(&self, other: &Column) -> bool
pub fn set_sorted_flag(&mut self, sorted: IsSorted)
pub fn get_flags(&self) -> StatisticsFlags
pub fn vec_hash( &self, build_hasher: PlRandomState, buf: &mut Vec<u64>, ) -> PolarsResult<()>
pub fn vec_hash_combine( &self, build_hasher: PlRandomState, hashes: &mut [u64], ) -> PolarsResult<()>
pub fn append(&mut self, other: &Column) -> PolarsResult<&mut Self>
pub fn arg_sort(&self, options: SortOptions) -> IdxCa
pub fn bit_repr(&self) -> Option<BitRepr>
pub fn into_frame(self) -> DataFrame
pub fn extend(&mut self, other: &Column) -> PolarsResult<&mut Self>
pub fn rechunk(&self) -> Column
pub fn explode(&self) -> PolarsResult<Column>
pub fn implode(&self) -> PolarsResult<ListChunked>
pub fn fill_null(&self, strategy: FillNullStrategy) -> PolarsResult<Self>
pub fn divide(&self, rhs: &Column) -> PolarsResult<Self>
pub fn shift(&self, periods: i64) -> Column
pub fn zip_with( &self, mask: &BooleanChunked, other: &Self, ) -> PolarsResult<Self>
zip_with
only.pub fn zip_with_same_type( &self, mask: &ChunkedArray<BooleanType>, other: &Column, ) -> PolarsResult<Column>
zip_with
only.pub fn drop_nulls(&self) -> Column
Sourcepub fn as_list(&self) -> ListChunked
pub fn as_list(&self) -> ListChunked
Packs every element into a list.
pub fn is_sorted_flag(&self) -> IsSorted
pub fn unique(&self) -> PolarsResult<Column>
pub fn unique_stable(&self) -> PolarsResult<Column>
pub fn reshape_list( &self, dimensions: &[ReshapeDimension], ) -> PolarsResult<Self>
pub fn reshape_array( &self, dimensions: &[ReshapeDimension], ) -> PolarsResult<Self>
dtype-array
only.pub fn sort(&self, sort_options: SortOptions) -> PolarsResult<Self>
pub fn filter(&self, filter: &BooleanChunked) -> PolarsResult<Self>
pub fn shuffle(&self, seed: Option<u64>) -> Self
random
only.pub fn sample_frac( &self, frac: f64, with_replacement: bool, shuffle: bool, seed: Option<u64>, ) -> PolarsResult<Self>
random
only.pub fn sample_n( &self, n: usize, with_replacement: bool, shuffle: bool, seed: Option<u64>, ) -> PolarsResult<Self>
random
only.pub fn gather_every(&self, n: usize, offset: usize) -> Column
pub fn extend_constant( &self, value: AnyValue<'_>, n: usize, ) -> PolarsResult<Self>
pub fn is_finite(&self) -> PolarsResult<BooleanChunked>
pub fn is_infinite(&self) -> PolarsResult<BooleanChunked>
pub fn is_nan(&self) -> PolarsResult<BooleanChunked>
pub fn is_not_nan(&self) -> PolarsResult<BooleanChunked>
pub fn wrapping_trunc_div_scalar<T>(&self, rhs: T) -> Self
pub fn product(&self) -> PolarsResult<Scalar>
pub fn phys_iter(&self) -> SeriesPhysIter<'_>
pub fn get(&self, index: usize) -> PolarsResult<AnyValue<'_>>
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> AnyValue<'_>
pub unsafe fn get_unchecked(&self, index: usize) -> AnyValue<'_>
§Safety
Does not perform bounds check on index
pub fn get_object(&self, index: usize) -> Option<&dyn PolarsObjectSafe>
object
only.pub fn bitand(&self, rhs: &Self) -> PolarsResult<Self>
pub fn bitor(&self, rhs: &Self) -> PolarsResult<Self>
pub fn bitxor(&self, rhs: &Self) -> PolarsResult<Self>
pub fn try_add_owned(self, other: Self) -> PolarsResult<Self>
pub fn try_sub_owned(self, other: Self) -> PolarsResult<Self>
pub fn try_mul_owned(self, other: Self) -> PolarsResult<Self>
pub fn min_reduce(&self) -> PolarsResult<Scalar>
pub fn max_reduce(&self) -> PolarsResult<Scalar>
pub fn median_reduce(&self) -> PolarsResult<Scalar>
pub fn mean_reduce(&self) -> Scalar
pub fn std_reduce(&self, ddof: u8) -> PolarsResult<Scalar>
pub fn var_reduce(&self, ddof: u8) -> PolarsResult<Scalar>
pub fn sum_reduce(&self) -> PolarsResult<Scalar>
pub fn and_reduce(&self) -> PolarsResult<Scalar>
pub fn or_reduce(&self) -> PolarsResult<Scalar>
pub fn xor_reduce(&self) -> PolarsResult<Scalar>
pub fn n_unique(&self) -> PolarsResult<usize>
pub fn quantile_reduce( &self, quantile: f64, method: QuantileMethod, ) -> PolarsResult<Scalar>
pub fn sort_with(&self, options: SortOptions) -> PolarsResult<Self>
pub fn map_unary_elementwise_to_bool( &self, f: impl Fn(&Series) -> BooleanChunked, ) -> BooleanChunked
pub fn try_map_unary_elementwise_to_bool( &self, f: impl Fn(&Series) -> PolarsResult<BooleanChunked>, ) -> PolarsResult<BooleanChunked>
pub fn apply_unary_elementwise(&self, f: impl Fn(&Series) -> Series) -> Column
pub fn try_apply_unary_elementwise( &self, f: impl Fn(&Series) -> PolarsResult<Series>, ) -> PolarsResult<Column>
pub fn apply_broadcasting_binary_elementwise( &self, other: &Self, op: impl Fn(&Series, &Series) -> Series, ) -> PolarsResult<Column>
pub fn try_apply_broadcasting_binary_elementwise( &self, other: &Self, op: impl Fn(&Series, &Series) -> PolarsResult<Series>, ) -> PolarsResult<Column>
pub fn apply_binary_elementwise( &self, other: &Self, f: impl Fn(&Series, &Series) -> Series, f_lb: impl Fn(&Scalar, &Series) -> Series, f_rb: impl Fn(&Series, &Scalar) -> Series, ) -> Column
pub fn try_apply_binary_elementwise( &self, other: &Self, f: impl Fn(&Series, &Series) -> PolarsResult<Series>, f_lb: impl Fn(&Scalar, &Series) -> PolarsResult<Series>, f_rb: impl Fn(&Series, &Scalar) -> PolarsResult<Series>, ) -> PolarsResult<Column>
pub fn n_chunks(&self) -> usize
Trait Implementations§
Source§impl ChunkCompareEq<&Column> for Column
impl ChunkCompareEq<&Column> for Column
Source§fn equal(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn equal(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking for equality.
Source§fn equal_missing(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn equal_missing(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking for equality.
Source§fn not_equal(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn not_equal(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking for inequality.
Source§fn not_equal_missing(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn not_equal_missing(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking for inequality.
type Item = Result<ChunkedArray<BooleanType>, PolarsError>
Source§impl ChunkCompareIneq<&Column> for Column
impl ChunkCompareIneq<&Column> for Column
Source§fn gt(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn gt(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking if self > rhs.
Source§fn gt_eq(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn gt_eq(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking if self >= rhs.
Source§fn lt(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn lt(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking if self < rhs.
Source§fn lt_eq(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
fn lt_eq(&self, rhs: &Column) -> PolarsResult<BooleanChunked>
Create a boolean mask by checking if self <= rhs.
type Item = Result<ChunkedArray<BooleanType>, PolarsError>
Source§impl<'de> Deserialize<'de> for Column
impl<'de> Deserialize<'de> for Column
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<ScalarColumn> for Column
impl From<ScalarColumn> for Column
Source§fn from(value: ScalarColumn) -> Self
fn from(value: ScalarColumn) -> Self
Source§impl FromIterator<Column> for DataFrame
impl FromIterator<Column> for DataFrame
Source§impl IntoColumn for Column
impl IntoColumn for Column
fn into_column(self) -> Column
Auto Trait Implementations§
impl !Freeze for Column
impl !RefUnwindSafe for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl !UnwindSafe for Column
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more