pub struct Breaks(/* private fields */);Expand description
Breakpoints delimiting bins by value.
Always free of nulls and non-decreasing.
Implementations§
Methods from Deref<Target = Series>§
Sourcepub fn fill_null(
&self,
strategy: FillNullStrategy,
) -> Result<Series, PolarsError>
pub fn fill_null( &self, strategy: FillNullStrategy, ) -> Result<Series, PolarsError>
Replace None values with one of the following strategies:
- Forward fill (replace None with the previous value)
- Backward fill (replace None with the next value)
- Mean fill (replace None with the mean of the whole array)
- Min fill (replace None with the minimum of the whole array)
- Max fill (replace None with the maximum of the whole array)
- Zero fill (replace None with the value zero)
- One fill (replace None with the value one)
NOTE: If you want to fill the Nones with a value use the
fill_null operation on ChunkedArray<T>.
§Example
fn example() -> PolarsResult<()> {
let s = Column::new("some_missing".into(), &[Some(1), None, Some(2)]);
let filled = s.fill_null(FillNullStrategy::Forward(None))?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);
let filled = s.fill_null(FillNullStrategy::Backward(None))?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(2), Some(2)]);
let filled = s.fill_null(FillNullStrategy::Min)?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);
let filled = s.fill_null(FillNullStrategy::Max)?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(2), Some(2)]);
let filled = s.fill_null(FillNullStrategy::Mean)?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);
let filled = s.fill_null(FillNullStrategy::Zero)?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(0), Some(2)]);
let filled = s.fill_null(FillNullStrategy::One)?;
assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);
Ok(())
}
example();pub fn sample_n( &self, n: usize, with_replacement: bool, shuffle: Option<bool>, seed: Option<u64>, ) -> Result<Series, PolarsError>
Sourcepub fn sample_frac(
&self,
frac: f64,
with_replacement: bool,
shuffle: Option<bool>,
seed: Option<u64>,
) -> Result<Series, PolarsError>
pub fn sample_frac( &self, frac: f64, with_replacement: bool, shuffle: Option<bool>, seed: Option<u64>, ) -> Result<Series, PolarsError>
Sample a fraction between 0.0-1.0 of this ChunkedArray.
pub fn shuffle(&self, seed: Option<u64>) -> Series
pub fn fmt_list(&self) -> String
pub fn serialize_into_writer( &self, writer: &mut dyn Write, ) -> Result<(), PolarsError>
pub fn serialize_to_bytes(&self) -> Result<Vec<u8>, PolarsError>
pub fn wrapping_trunc_div_scalar<T>(&self, rhs: T) -> Series
Sourcepub fn to_arrow(
&self,
chunk_idx: usize,
compat_level: CompatLevel,
) -> Box<dyn Array>
pub fn to_arrow( &self, chunk_idx: usize, compat_level: CompatLevel, ) -> Box<dyn Array>
Export this Series to an arrow array. The dtype of the returned array will be chosen
according to the provided compat_level.
Sourcepub fn to_arrow_with_field<'a>(
&self,
chunk_idx: usize,
output_arrow_field: Cow<'a, Field>,
skip_attach_pl_metadata: bool,
) -> Result<Box<dyn Array>, PolarsError>
pub fn to_arrow_with_field<'a>( &self, chunk_idx: usize, output_arrow_field: Cow<'a, Field>, skip_attach_pl_metadata: bool, ) -> Result<Box<dyn Array>, PolarsError>
Export this Series to an arrow array. The dtype of the returned array will match the provided arrow field. Returns an error if this Series cannot be exported to the arrow field.
Sourcepub fn iter(&self) -> SeriesIter<'_> ⓘ
pub fn iter(&self) -> SeriesIter<'_> ⓘ
Sourcepub fn canonicalize_maps(&self) -> Result<Option<Series>, PolarsError>
pub fn canonicalize_maps(&self) -> Result<Option<Series>, PolarsError>
Canonicalize all nested Maps bottom-up using first-position/last-value
semantics. Returns None if unchanged.
Sourcepub fn try_i8(&self) -> Option<&ChunkedArray<Int8Type>>
pub fn try_i8(&self) -> Option<&ChunkedArray<Int8Type>>
Unpack to ChunkedArray of dtype DataType::Int8
Sourcepub fn try_i16(&self) -> Option<&ChunkedArray<Int16Type>>
pub fn try_i16(&self) -> Option<&ChunkedArray<Int16Type>>
Unpack to ChunkedArray of dtype DataType::Int16
Sourcepub fn try_i32(&self) -> Option<&ChunkedArray<Int32Type>>
pub fn try_i32(&self) -> Option<&ChunkedArray<Int32Type>>
Unpack to ChunkedArray
let s = Series::new("foo".into(), [1i32 ,2, 3]);
let s_squared: Series = s.i32()
.unwrap()
.iter()
.map(|opt_v| {
match opt_v {
Some(v) => Some(v * v),
None => None, // null value
}
}).collect();Unpack to ChunkedArray of dtype DataType::Int32
Sourcepub fn try_i64(&self) -> Option<&ChunkedArray<Int64Type>>
pub fn try_i64(&self) -> Option<&ChunkedArray<Int64Type>>
Unpack to ChunkedArray of dtype DataType::Int64
Sourcepub fn try_i128(&self) -> Option<&ChunkedArray<Int128Type>>
Available on crate feature dtype-i128 only.
pub fn try_i128(&self) -> Option<&ChunkedArray<Int128Type>>
dtype-i128 only.Unpack to ChunkedArray of dtype DataType::Int128
Sourcepub fn try_f16(&self) -> Option<&ChunkedArray<Float16Type>>
Available on crate feature dtype-f16 only.
pub fn try_f16(&self) -> Option<&ChunkedArray<Float16Type>>
dtype-f16 only.Unpack to ChunkedArray of dtype DataType::Float16
Sourcepub fn try_f32(&self) -> Option<&ChunkedArray<Float32Type>>
pub fn try_f32(&self) -> Option<&ChunkedArray<Float32Type>>
Unpack to ChunkedArray of dtype DataType::Float32
Sourcepub fn try_f64(&self) -> Option<&ChunkedArray<Float64Type>>
pub fn try_f64(&self) -> Option<&ChunkedArray<Float64Type>>
Unpack to ChunkedArray of dtype DataType::Float64
Sourcepub fn try_u8(&self) -> Option<&ChunkedArray<UInt8Type>>
pub fn try_u8(&self) -> Option<&ChunkedArray<UInt8Type>>
Unpack to ChunkedArray of dtype DataType::UInt8
Sourcepub fn try_u16(&self) -> Option<&ChunkedArray<UInt16Type>>
pub fn try_u16(&self) -> Option<&ChunkedArray<UInt16Type>>
Unpack to ChunkedArray of dtype DataType::UInt16
Sourcepub fn try_u32(&self) -> Option<&ChunkedArray<UInt32Type>>
pub fn try_u32(&self) -> Option<&ChunkedArray<UInt32Type>>
Unpack to ChunkedArray of dtype DataType::UInt32
Sourcepub fn try_u64(&self) -> Option<&ChunkedArray<UInt64Type>>
pub fn try_u64(&self) -> Option<&ChunkedArray<UInt64Type>>
Unpack to ChunkedArray of dtype DataType::UInt64
Sourcepub fn try_u128(&self) -> Option<&ChunkedArray<UInt128Type>>
Available on crate feature dtype-u128 only.
pub fn try_u128(&self) -> Option<&ChunkedArray<UInt128Type>>
dtype-u128 only.Unpack to ChunkedArray of dtype DataType::UInt128
Sourcepub fn try_bool(&self) -> Option<&ChunkedArray<BooleanType>>
pub fn try_bool(&self) -> Option<&ChunkedArray<BooleanType>>
Unpack to ChunkedArray of dtype DataType::Boolean
Sourcepub fn try_str(&self) -> Option<&ChunkedArray<StringType>>
pub fn try_str(&self) -> Option<&ChunkedArray<StringType>>
Unpack to ChunkedArray of dtype DataType::String
Sourcepub fn try_binary(&self) -> Option<&ChunkedArray<BinaryType>>
pub fn try_binary(&self) -> Option<&ChunkedArray<BinaryType>>
Unpack to ChunkedArray of dtype DataType::Binary
Sourcepub fn try_binary_offset(&self) -> Option<&ChunkedArray<BinaryOffsetType>>
pub fn try_binary_offset(&self) -> Option<&ChunkedArray<BinaryOffsetType>>
Unpack to ChunkedArray of dtype DataType::Binary
Sourcepub fn try_time(&self) -> Option<&Logical<TimeType, Int64Type>>
Available on crate feature dtype-time only.
pub fn try_time(&self) -> Option<&Logical<TimeType, Int64Type>>
dtype-time only.Unpack to ChunkedArray of dtype DataType::Time
Sourcepub fn try_date(&self) -> Option<&Logical<DateType, Int32Type>>
Available on crate feature dtype-date only.
pub fn try_date(&self) -> Option<&Logical<DateType, Int32Type>>
dtype-date only.Unpack to ChunkedArray of dtype DataType::Date
Sourcepub fn try_datetime(&self) -> Option<&Logical<DatetimeType, Int64Type>>
Available on crate feature dtype-datetime only.
pub fn try_datetime(&self) -> Option<&Logical<DatetimeType, Int64Type>>
dtype-datetime only.Unpack to ChunkedArray of dtype DataType::Datetime
Sourcepub fn try_duration(&self) -> Option<&Logical<DurationType, Int64Type>>
Available on crate feature dtype-duration only.
pub fn try_duration(&self) -> Option<&Logical<DurationType, Int64Type>>
dtype-duration only.Unpack to ChunkedArray of dtype DataType::Duration
Sourcepub fn try_decimal(&self) -> Option<&Logical<DecimalType, Int128Type>>
Available on crate feature dtype-decimal only.
pub fn try_decimal(&self) -> Option<&Logical<DecimalType, Int128Type>>
dtype-decimal only.Unpack to ChunkedArray of dtype DataType::Decimal
Sourcepub fn try_list(&self) -> Option<&ChunkedArray<ListType>>
pub fn try_list(&self) -> Option<&ChunkedArray<ListType>>
Unpack to ChunkedArray of dtype list
Sourcepub fn try_array(&self) -> Option<&ChunkedArray<FixedSizeListType>>
Available on crate feature dtype-array only.
pub fn try_array(&self) -> Option<&ChunkedArray<FixedSizeListType>>
dtype-array only.Unpack to ChunkedArray of dtype DataType::Array
pub fn try_cat<T>(
&self,
) -> Option<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>>where
T: PolarsCategoricalType,
dtype-categorical only.Sourcepub fn try_cat8(
&self,
) -> Option<&Logical<Categorical8Type, <Categorical8Type as PolarsCategoricalType>::PolarsPhysical>>
Available on crate feature dtype-categorical only.
pub fn try_cat8( &self, ) -> Option<&Logical<Categorical8Type, <Categorical8Type as PolarsCategoricalType>::PolarsPhysical>>
dtype-categorical only.Unpack to ChunkedArray of dtype DataType::Categorical or DataType::Enum with a physical type of UInt8.
pub fn try_cat16( &self, ) -> Option<&Logical<Categorical16Type, <Categorical16Type as PolarsCategoricalType>::PolarsPhysical>>
dtype-categorical only.pub fn try_cat32( &self, ) -> Option<&Logical<Categorical32Type, <Categorical32Type as PolarsCategoricalType>::PolarsPhysical>>
dtype-categorical only.Sourcepub fn try_map(&self) -> Option<&MapChunked>
Available on crate feature dtype-map only.
pub fn try_map(&self) -> Option<&MapChunked>
dtype-map only.Unpack to MapChunked of dtype DataType::Map.
Sourcepub fn try_struct(&self) -> Option<&ChunkedArray<StructType>>
Available on crate feature dtype-struct only.
pub fn try_struct(&self) -> Option<&ChunkedArray<StructType>>
dtype-struct only.Unpack to ChunkedArray of dtype DataType::Struct
Sourcepub fn try_null(&self) -> Option<&NullChunked>
pub fn try_null(&self) -> Option<&NullChunked>
Unpack to ChunkedArray of dtype DataType::Null
Sourcepub fn i8(&self) -> Result<&ChunkedArray<Int8Type>, PolarsError>
pub fn i8(&self) -> Result<&ChunkedArray<Int8Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Int8
Sourcepub fn i16(&self) -> Result<&ChunkedArray<Int16Type>, PolarsError>
pub fn i16(&self) -> Result<&ChunkedArray<Int16Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Int16
Sourcepub fn i32(&self) -> Result<&ChunkedArray<Int32Type>, PolarsError>
pub fn i32(&self) -> Result<&ChunkedArray<Int32Type>, PolarsError>
Unpack to ChunkedArray
let s = Series::new("foo".into(), [1i32 ,2, 3]);
let s_squared: Series = s.i32()
.unwrap()
.iter()
.map(|opt_v| {
match opt_v {
Some(v) => Some(v * v),
None => None, // null value
}
}).collect();Unpack to ChunkedArray of dtype DataType::Int32
Sourcepub fn i64(&self) -> Result<&ChunkedArray<Int64Type>, PolarsError>
pub fn i64(&self) -> Result<&ChunkedArray<Int64Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Int64
Sourcepub fn i128(&self) -> Result<&ChunkedArray<Int128Type>, PolarsError>
Available on crate feature dtype-i128 only.
pub fn i128(&self) -> Result<&ChunkedArray<Int128Type>, PolarsError>
dtype-i128 only.Unpack to ChunkedArray of dtype DataType::Int128
Sourcepub fn f16(&self) -> Result<&ChunkedArray<Float16Type>, PolarsError>
Available on crate feature dtype-f16 only.
pub fn f16(&self) -> Result<&ChunkedArray<Float16Type>, PolarsError>
dtype-f16 only.Unpack to ChunkedArray of dtype DataType::Float16
Sourcepub fn f32(&self) -> Result<&ChunkedArray<Float32Type>, PolarsError>
pub fn f32(&self) -> Result<&ChunkedArray<Float32Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Float32
Sourcepub fn f64(&self) -> Result<&ChunkedArray<Float64Type>, PolarsError>
pub fn f64(&self) -> Result<&ChunkedArray<Float64Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Float64
Sourcepub fn u8(&self) -> Result<&ChunkedArray<UInt8Type>, PolarsError>
pub fn u8(&self) -> Result<&ChunkedArray<UInt8Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::UInt8
Sourcepub fn u16(&self) -> Result<&ChunkedArray<UInt16Type>, PolarsError>
pub fn u16(&self) -> Result<&ChunkedArray<UInt16Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::UInt16
Sourcepub fn u32(&self) -> Result<&ChunkedArray<UInt32Type>, PolarsError>
pub fn u32(&self) -> Result<&ChunkedArray<UInt32Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::UInt32
Sourcepub fn u64(&self) -> Result<&ChunkedArray<UInt64Type>, PolarsError>
pub fn u64(&self) -> Result<&ChunkedArray<UInt64Type>, PolarsError>
Unpack to ChunkedArray of dtype DataType::UInt64
Sourcepub fn u128(&self) -> Result<&ChunkedArray<UInt128Type>, PolarsError>
Available on crate feature dtype-u128 only.
pub fn u128(&self) -> Result<&ChunkedArray<UInt128Type>, PolarsError>
dtype-u128 only.Unpack to ChunkedArray of dtype DataType::UInt128
Sourcepub fn bool(&self) -> Result<&ChunkedArray<BooleanType>, PolarsError>
pub fn bool(&self) -> Result<&ChunkedArray<BooleanType>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Boolean
Sourcepub fn str(&self) -> Result<&ChunkedArray<StringType>, PolarsError>
pub fn str(&self) -> Result<&ChunkedArray<StringType>, PolarsError>
Unpack to ChunkedArray of dtype DataType::String
Sourcepub fn binary(&self) -> Result<&ChunkedArray<BinaryType>, PolarsError>
pub fn binary(&self) -> Result<&ChunkedArray<BinaryType>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Binary
Sourcepub fn binary_offset(
&self,
) -> Result<&ChunkedArray<BinaryOffsetType>, PolarsError>
pub fn binary_offset( &self, ) -> Result<&ChunkedArray<BinaryOffsetType>, PolarsError>
Unpack to ChunkedArray of dtype DataType::Binary
Sourcepub fn time(&self) -> Result<&Logical<TimeType, Int64Type>, PolarsError>
Available on crate feature dtype-time only.
pub fn time(&self) -> Result<&Logical<TimeType, Int64Type>, PolarsError>
dtype-time only.Unpack to ChunkedArray of dtype DataType::Time
Sourcepub fn date(&self) -> Result<&Logical<DateType, Int32Type>, PolarsError>
Available on crate feature dtype-date only.
pub fn date(&self) -> Result<&Logical<DateType, Int32Type>, PolarsError>
dtype-date only.Unpack to ChunkedArray of dtype DataType::Date
Sourcepub fn datetime(&self) -> Result<&Logical<DatetimeType, Int64Type>, PolarsError>
Available on crate feature dtype-datetime only.
pub fn datetime(&self) -> Result<&Logical<DatetimeType, Int64Type>, PolarsError>
dtype-datetime only.Unpack to ChunkedArray of dtype DataType::Datetime
Sourcepub fn duration(&self) -> Result<&Logical<DurationType, Int64Type>, PolarsError>
Available on crate feature dtype-duration only.
pub fn duration(&self) -> Result<&Logical<DurationType, Int64Type>, PolarsError>
dtype-duration only.Unpack to ChunkedArray of dtype DataType::Duration
Sourcepub fn decimal(&self) -> Result<&Logical<DecimalType, Int128Type>, PolarsError>
Available on crate feature dtype-decimal only.
pub fn decimal(&self) -> Result<&Logical<DecimalType, Int128Type>, PolarsError>
dtype-decimal only.Unpack to ChunkedArray of dtype DataType::Decimal
Sourcepub fn list(&self) -> Result<&ChunkedArray<ListType>, PolarsError>
pub fn list(&self) -> Result<&ChunkedArray<ListType>, PolarsError>
Unpack to ChunkedArray of dtype list
Sourcepub fn array(&self) -> Result<&ChunkedArray<FixedSizeListType>, PolarsError>
Available on crate feature dtype-array only.
pub fn array(&self) -> Result<&ChunkedArray<FixedSizeListType>, PolarsError>
dtype-array only.Unpack to ChunkedArray of dtype DataType::Array
Sourcepub fn cat<T>(
&self,
) -> Result<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>, PolarsError>where
T: PolarsCategoricalType,
Available on crate feature dtype-categorical only.
pub fn cat<T>(
&self,
) -> Result<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>, PolarsError>where
T: PolarsCategoricalType,
dtype-categorical only.Unpack to ChunkedArray of dtype DataType::Categorical or DataType::Enum.
Sourcepub fn cat8(
&self,
) -> Result<&Logical<Categorical8Type, <Categorical8Type as PolarsCategoricalType>::PolarsPhysical>, PolarsError>
Available on crate feature dtype-categorical only.
pub fn cat8( &self, ) -> Result<&Logical<Categorical8Type, <Categorical8Type as PolarsCategoricalType>::PolarsPhysical>, PolarsError>
dtype-categorical only.Unpack to ChunkedArray of dtype DataType::Categorical or DataType::Enum with a physical type of UInt8.
Sourcepub fn cat16(
&self,
) -> Result<&Logical<Categorical16Type, <Categorical16Type as PolarsCategoricalType>::PolarsPhysical>, PolarsError>
Available on crate feature dtype-categorical only.
pub fn cat16( &self, ) -> Result<&Logical<Categorical16Type, <Categorical16Type as PolarsCategoricalType>::PolarsPhysical>, PolarsError>
dtype-categorical only.Unpack to ChunkedArray of dtype DataType::Categorical or DataType::Enum with a physical type of UInt16.
Sourcepub fn cat32(
&self,
) -> Result<&Logical<Categorical32Type, <Categorical32Type as PolarsCategoricalType>::PolarsPhysical>, PolarsError>
Available on crate feature dtype-categorical only.
pub fn cat32( &self, ) -> Result<&Logical<Categorical32Type, <Categorical32Type as PolarsCategoricalType>::PolarsPhysical>, PolarsError>
dtype-categorical only.Unpack to ChunkedArray of dtype DataType::Categorical or DataType::Enum with a physical type of UInt32.
Sourcepub fn struct_(&self) -> Result<&ChunkedArray<StructType>, PolarsError>
Available on crate feature dtype-struct only.
pub fn struct_(&self) -> Result<&ChunkedArray<StructType>, PolarsError>
dtype-struct only.Unpack to ChunkedArray of dtype DataType::Struct
Sourcepub fn map(&self) -> Result<&MapChunked, PolarsError>
Available on crate feature dtype-map only.
pub fn map(&self) -> Result<&MapChunked, PolarsError>
dtype-map only.Unpack to MapChunked of dtype DataType::Map.
Sourcepub fn null(&self) -> Result<&NullChunked, PolarsError>
pub fn null(&self) -> Result<&NullChunked, PolarsError>
Unpack to ChunkedArray of dtype DataType::Null
Sourcepub fn extend_constant(
&self,
value: AnyValue<'_>,
n: usize,
) -> Result<Series, PolarsError>
pub fn extend_constant( &self, value: AnyValue<'_>, n: usize, ) -> Result<Series, PolarsError>
Extend with a constant value.
Sourcepub fn try_from_physical(&self, dtype: &DataType) -> Result<Series, PolarsError>
pub fn try_from_physical(&self, dtype: &DataType) -> Result<Series, PolarsError>
Restore dtype from its physical representation with safety and Arrow import checks.
Safe counterpart of Series::from_physical_unchecked.
Map: validate and canonicalize storage before constructing the Map.Categorical/Enum: every code must name a category.Decimal: validate the precision and scale, and that the values fit.Object,Unknown: reject reconstruction.- Temporal types: no per-value checks, matching Arrow import. Out-of-range
Timevalues may fail during formatting.
Errors for unsupported dtypes.
Sourcepub fn get_leaf_array(&self) -> Series
pub fn get_leaf_array(&self) -> Series
Recurse nested types until we are at the leaf array.
Sourcepub fn list_offsets_and_validities_recursive(
&self,
) -> (Vec<OffsetsBuffer<i64>>, Vec<Option<Bitmap>>)
pub fn list_offsets_and_validities_recursive( &self, ) -> (Vec<OffsetsBuffer<i64>>, Vec<Option<Bitmap>>)
TODO: Move this somewhere else?
Sourcepub fn to_unit_list(&self) -> ChunkedArray<ListType>
pub fn to_unit_list(&self) -> ChunkedArray<ListType>
Wrap each element of this Series in a single-element list.
A Series [1, 2, 3] becomes [[1], [2], [3]].
Sourcepub fn implode(&self) -> Result<ChunkedArray<ListType>, PolarsError>
pub fn implode(&self) -> Result<ChunkedArray<ListType>, PolarsError>
Convert the values of this Series to a ListChunked with a length of 1,
so a Series of [1, 2, 3] becomes [[1, 2, 3]].
pub fn reshape_array( &self, dimensions: &[ReshapeDimension], ) -> Result<Series, PolarsError>
dtype-array only.pub fn reshape_list( &self, dimensions: &[ReshapeDimension], ) -> Result<Series, PolarsError>
pub fn clear(&self) -> Series
Sourcepub fn array_ref(&self, chunk_idx: usize) -> &Box<dyn Array>
pub fn array_ref(&self, chunk_idx: usize) -> &Box<dyn Array>
Returns a reference to the Arrow ArrayRef
pub fn select_chunk(&self, i: usize) -> Series
pub fn is_sorted_flag(&self) -> IsSorted
pub fn get_flags(&self) -> StatisticsFlags
Sourcepub fn broadcast_to(
&self,
length: usize,
) -> Result<Cow<'_, Series>, PolarsError>
pub fn broadcast_to( &self, length: usize, ) -> Result<Cow<'_, Series>, PolarsError>
Returns a series with the given length.
Errors if this series’ length is not 1 and also not equal to the requested length.
Sourcepub fn sort(&self, sort_options: SortOptions) -> Result<Series, PolarsError>
pub fn sort(&self, sort_options: SortOptions) -> Result<Series, PolarsError>
Sort the series with specific options.
§Example
let s = Series::new("foo".into(), [2, 1, 3]);
let sorted = s.sort(SortOptions::default())?;
assert_eq!(sorted, Series::new("foo".into(), [1, 2, 3]));
}See SortOptions for more options.
pub fn cast(&self, dtype: &DataType) -> Result<Series, PolarsError>
Sourcepub fn cast_with_options(
&self,
dtype: &DataType,
options: CastOptions,
) -> Result<Series, PolarsError>
pub fn cast_with_options( &self, dtype: &DataType, options: CastOptions, ) -> Result<Series, PolarsError>
Sourcepub unsafe fn cast_unchecked(
&self,
dtype: &DataType,
) -> Result<Series, PolarsError>
pub unsafe fn cast_unchecked( &self, dtype: &DataType, ) -> Result<Series, PolarsError>
Cast from physical to logical types without any checks on the validity of the cast.
§Safety
This can lead to invalid memory access in downstream code.
Sourcepub unsafe fn from_physical_unchecked(
&self,
dtype: &DataType,
) -> Result<Series, PolarsError>
pub unsafe fn from_physical_unchecked( &self, dtype: &DataType, ) -> Result<Series, PolarsError>
Convert a non-logical series back into a logical series without casting.
§Safety
Payloads must be safe to read as dtype: categorical codes in range for every
non-null slot, and Maps satisfying the MapChunked storage safety contract. Null
Map rows may span entries, and those entries may themselves be null; they are left
alone. Null entries or keys in live rows are errors. Unsafe payloads can cause
invalid memory access downstream.
§Key uniqueness
Not required for safety. Whole-row transformations preserve existing uniqueness; key-changing transformations must use validated construction.
Sourcepub fn to_float(&self) -> Result<Series, PolarsError>
pub fn to_float(&self) -> Result<Series, PolarsError>
Cast numerical types to f64, and keep floats as is.
Sourcepub fn sum<T>(&self) -> Result<T, PolarsError>
pub fn sum<T>(&self) -> Result<T, PolarsError>
Get the sum of the Series as a Scalar.
Returns a Scalar with a zeroed value if self is an empty numeric series.
If the DataType is one of {Int8, UInt8, Int16, UInt16} the sum is
computed in an Int64 accumulator and the result is returned as Int64
to prevent overflow issues.
Sourcepub fn min<T>(&self) -> Result<Option<T>, PolarsError>
pub fn min<T>(&self) -> Result<Option<T>, PolarsError>
Returns the minimum value in the array, according to the natural order. Returns an option because the array is nullable.
Sourcepub fn max<T>(&self) -> Result<Option<T>, PolarsError>
pub fn max<T>(&self) -> Result<Option<T>, PolarsError>
Returns the maximum value in the array, according to the natural order. Returns an option because the array is nullable.
Sourcepub fn explode(&self, options: ExplodeOptions) -> Result<Series, PolarsError>
pub fn explode(&self, options: ExplodeOptions) -> Result<Series, PolarsError>
Explode a list Series. This expands every item to a new row..
Sourcepub fn is_nan(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
pub fn is_nan(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
Check if numeric value is NaN (note this is different than missing/ null)
Sourcepub fn is_not_nan(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
pub fn is_not_nan(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
Check if numeric value is NaN (note this is different than missing/null)
Sourcepub fn is_finite(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
pub fn is_finite(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
Check if numeric value is finite
Sourcepub fn is_infinite(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
pub fn is_infinite(&self) -> Result<ChunkedArray<BooleanType>, PolarsError>
Check if numeric value is infinite
Sourcepub fn zip_with(
&self,
mask: &ChunkedArray<BooleanType>,
other: &Series,
) -> Result<Series, PolarsError>
Available on crate feature zip_with only.
pub fn zip_with( &self, mask: &ChunkedArray<BooleanType>, other: &Series, ) -> Result<Series, PolarsError>
zip_with only.Create a new ChunkedArray with values from self where the mask evaluates true and values
from other where the mask evaluates false. This function automatically broadcasts unit
length inputs.
Sourcepub fn to_physical_repr(&self) -> Cow<'_, Series>
pub fn to_physical_repr(&self) -> Cow<'_, Series>
Converts a Series to their physical representation, if they have one, otherwise the series is left unchanged.
- Date -> Int32
- Datetime -> Int64
- Duration -> Int64
- Decimal -> Int128
- Time -> Int64
- Categorical -> U8/U16/U32
- List(inner) -> List(physical of inner)
- Array(inner) -> Array(physical of inner)
- Struct -> Struct with physical repr of each struct column
- Extension -> physical of storage type
Sourcepub fn to_storage(&self) -> &Series
pub fn to_storage(&self) -> &Series
If the Series is an Extension type, return its storage Series. Otherwise, return itself.
Sourcepub fn gather_every(
&self,
n: usize,
offset: usize,
) -> Result<Series, PolarsError>
pub fn gather_every( &self, n: usize, offset: usize, ) -> Result<Series, PolarsError>
Traverse and collect every nth element in a new array.
Sourcepub fn sum_reduce(&self) -> Result<Scalar, PolarsError>
pub fn sum_reduce(&self) -> Result<Scalar, PolarsError>
Get the sum of the ChunkedArray as a Scalar.
Returns a Scalar with a single zeroed value if self is an empty numeric series.
If the DataType is one of {Int8, UInt8, Int16, UInt16} the sum is
computed in an Int64 accumulator and the result is returned as Int64
to prevent overflow issues.
Sourcepub fn mean_reduce(&self) -> Result<Scalar, PolarsError>
pub fn mean_reduce(&self) -> Result<Scalar, PolarsError>
Get the mean of the Series as a new Series of length 1. Returns a Series with a single null entry if self is an empty numeric series.
Sourcepub fn product(&self) -> Result<Scalar, PolarsError>
pub fn product(&self) -> Result<Scalar, PolarsError>
Get the product of an array.
If the DataType is one of {Int8, UInt8, Int16, UInt16} the Series is
first cast to Int64 to prevent overflow issues.
Sourcepub fn strict_cast(&self, dtype: &DataType) -> Result<Series, PolarsError>
pub fn strict_cast(&self, dtype: &DataType) -> Result<Series, PolarsError>
Cast throws an error if conversion had overflows
pub fn str_value(&self, index: usize) -> Result<Cow<'_, str>, PolarsError>
Sourcepub fn unique_stable(&self) -> Result<Series, PolarsError>
pub fn unique_stable(&self) -> Result<Series, PolarsError>
Compute the unique elements, but maintain order. This requires more work
than a naive Series::unique.
pub fn try_idx(&self) -> Option<&ChunkedArray<UInt32Type>>
pub fn idx(&self) -> Result<&ChunkedArray<UInt32Type>, PolarsError>
Sourcepub fn estimated_size(&self) -> usize
pub fn estimated_size(&self) -> usize
Returns an estimation of the total (heap) allocated size of the Series in bytes.
§Implementation
This estimation is the sum of the size of its buffers, validity, including nested arrays.
Multiple arrays may share buffers and bitmaps. Therefore, the size of 2 arrays is not the
sum of the sizes computed from this function. In particular, StructArray’s size is an upper bound.
When an array is sliced, its allocated size remains constant because the buffer unchanged. However, this function will yield a smaller number. This is because this function returns the visible size of the buffer, not its total capacity.
FFI buffers are included in this estimation.
pub fn row_encode_unordered( &self, ) -> Result<ChunkedArray<BinaryOffsetType>, PolarsError>
pub fn row_encode_ordered( &self, descending: bool, nulls_last: bool, ) -> Result<ChunkedArray<BinaryOffsetType>, PolarsError>
Sourcepub fn equals(&self, other: &Series) -> bool
pub fn equals(&self, other: &Series) -> bool
Check if series are equal. Note that None == None evaluates to false
Sourcepub fn equals_missing(&self, other: &Series) -> bool
pub fn equals_missing(&self, other: &Series) -> bool
Check if all values in series are equal where None == None evaluates to true.
Methods from Deref<Target = dyn SeriesTrait>§
pub fn unpack<T>(&self) -> Result<&ChunkedArray<T>, PolarsError>where
T: PolarsPhysicalType,
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Breaks
impl<'de> Deserialize<'de> for Breaks
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Breaks, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Breaks, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Breaks
impl Serialize for Breaks
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Breaks
Auto Trait Implementations§
impl !RefUnwindSafe for Breaks
impl !UnwindSafe for Breaks
impl Freeze for Breaks
impl Send for Breaks
impl Sync for Breaks
impl Unpin for Breaks
impl UnsafeUnpin for Breaks
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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