Trait polars::prelude::SeriesTrait  
source · pub trait SeriesTrait: Send + Sync + PrivateSeries + PrivateSeriesNumeric {
Show 57 methods
    // Required methods
    fn rename(&mut self, name: &str);
    fn chunk_lengths(
        &self
    ) -> Map<Iter<'_, Box<dyn Array>>, fn(_: &Box<dyn Array>) -> usize> ⓘ;
    fn name(&self) -> &str;
    fn chunks(&self) -> &Vec<Box<dyn Array>>;
    unsafe fn chunks_mut(&mut self) -> &mut Vec<Box<dyn Array>>;
    fn slice(&self, _offset: i64, _length: usize) -> Series;
    fn filter(
        &self,
        _filter: &ChunkedArray<BooleanType>
    ) -> Result<Series, PolarsError>;
    fn take(
        &self,
        _indices: &ChunkedArray<UInt32Type>
    ) -> Result<Series, PolarsError>;
    unsafe fn take_unchecked(&self, _idx: &ChunkedArray<UInt32Type>) -> Series;
    fn take_slice(&self, _indices: &[u32]) -> Result<Series, PolarsError>;
    unsafe fn take_slice_unchecked(&self, _idx: &[u32]) -> Series;
    fn len(&self) -> usize;
    fn rechunk(&self) -> Series;
    fn new_from_index(&self, _index: usize, _length: usize) -> Series;
    fn cast(
        &self,
        _data_type: &DataType,
        options: CastOptions
    ) -> Result<Series, PolarsError>;
    fn get(&self, _index: usize) -> Result<AnyValue<'_>, PolarsError>;
    fn null_count(&self) -> usize;
    fn has_validity(&self) -> bool;
    fn is_null(&self) -> ChunkedArray<BooleanType>;
    fn is_not_null(&self) -> ChunkedArray<BooleanType>;
    fn reverse(&self) -> Series;
    fn shift(&self, _periods: i64) -> Series;
    fn clone_inner(&self) -> Arc<dyn SeriesTrait>;
    fn as_any(&self) -> &(dyn Any + 'static);
    // Provided methods
    fn bitand(&self, _other: &Series) -> Result<Series, PolarsError> { ... }
    fn bitor(&self, _other: &Series) -> Result<Series, PolarsError> { ... }
    fn bitxor(&self, _other: &Series) -> Result<Series, PolarsError> { ... }
    fn field(&self) -> Cow<'_, Field> { ... }
    fn dtype(&self) -> &DataType { ... }
    fn n_chunks(&self) -> usize { ... }
    fn shrink_to_fit(&mut self) { ... }
    fn limit(&self, num_elements: usize) -> Series { ... }
    fn is_empty(&self) -> bool { ... }
    fn drop_nulls(&self) -> Series { ... }
    fn mean(&self) -> Option<f64> { ... }
    fn std(&self, _ddof: u8) -> Option<f64> { ... }
    fn var(&self, _ddof: u8) -> Option<f64> { ... }
    fn median(&self) -> Option<f64> { ... }
    unsafe fn get_unchecked(&self, _index: usize) -> AnyValue<'_> { ... }
    fn sort_with(&self, _options: SortOptions) -> Result<Series, PolarsError> { ... }
    fn arg_sort(&self, options: SortOptions) -> ChunkedArray<UInt32Type> { ... }
    fn unique(&self) -> Result<Series, PolarsError> { ... }
    fn n_unique(&self) -> Result<usize, PolarsError> { ... }
    fn arg_unique(&self) -> Result<ChunkedArray<UInt32Type>, PolarsError> { ... }
    fn as_single_ptr(&mut self) -> Result<usize, PolarsError> { ... }
    fn sum_reduce(&self) -> Result<Scalar, PolarsError> { ... }
    fn max_reduce(&self) -> Result<Scalar, PolarsError> { ... }
    fn min_reduce(&self) -> Result<Scalar, PolarsError> { ... }
    fn median_reduce(&self) -> Result<Scalar, PolarsError> { ... }
    fn var_reduce(&self, _ddof: u8) -> Result<Scalar, PolarsError> { ... }
    fn std_reduce(&self, _ddof: u8) -> Result<Scalar, PolarsError> { ... }
    fn quantile_reduce(
        &self,
        _quantile: f64,
        _interpol: QuantileInterpolOptions
    ) -> Result<Scalar, PolarsError> { ... }
    fn get_object(
        &self,
        _index: usize
    ) -> Option<&(dyn PolarsObjectSafe + 'static)> { ... }
    unsafe fn get_object_chunked_unchecked(
        &self,
        _chunk: usize,
        _index: usize
    ) -> Option<&(dyn PolarsObjectSafe + 'static)> { ... }
    fn as_any_mut(&mut self) -> &mut (dyn Any + 'static) { ... }
    fn checked_div(&self, _rhs: &Series) -> Result<Series, PolarsError> { ... }
    fn rolling_map(
        &self,
        _f: &dyn Fn(&Series) -> Series,
        _options: RollingOptionsFixedWindow
    ) -> Result<Series, PolarsError> { ... }
}Required Methods§
sourcefn chunk_lengths(
    &self
) -> Map<Iter<'_, Box<dyn Array>>, fn(_: &Box<dyn Array>) -> usize> ⓘ
 
fn chunk_lengths( &self ) -> Map<Iter<'_, Box<dyn Array>>, fn(_: &Box<dyn Array>) -> usize> ⓘ
Get the lengths of the underlying chunks
sourceunsafe fn chunks_mut(&mut self) -> &mut Vec<Box<dyn Array>>
 
unsafe fn chunks_mut(&mut self) -> &mut Vec<Box<dyn Array>>
Underlying chunks.
§Safety
The caller must ensure the length and the data types of ArrayRef does not change.
sourcefn slice(&self, _offset: i64, _length: usize) -> Series
 
fn slice(&self, _offset: i64, _length: usize) -> Series
Get a zero copy view of the data.
When offset is negative the offset is counted from the end of the array
sourcefn filter(
    &self,
    _filter: &ChunkedArray<BooleanType>
) -> Result<Series, PolarsError>
 
fn filter( &self, _filter: &ChunkedArray<BooleanType> ) -> Result<Series, PolarsError>
Filter by boolean mask. This operation clones data.
sourcefn take(
    &self,
    _indices: &ChunkedArray<UInt32Type>
) -> Result<Series, PolarsError>
 
fn take( &self, _indices: &ChunkedArray<UInt32Type> ) -> Result<Series, PolarsError>
Take by index. This operation is clone.
sourceunsafe fn take_unchecked(&self, _idx: &ChunkedArray<UInt32Type>) -> Series
 
unsafe fn take_unchecked(&self, _idx: &ChunkedArray<UInt32Type>) -> Series
sourcefn take_slice(&self, _indices: &[u32]) -> Result<Series, PolarsError>
 
fn take_slice(&self, _indices: &[u32]) -> Result<Series, PolarsError>
Take by index. This operation is clone.
sourceunsafe fn take_slice_unchecked(&self, _idx: &[u32]) -> Series
 
unsafe fn take_slice_unchecked(&self, _idx: &[u32]) -> Series
sourcefn new_from_index(&self, _index: usize, _length: usize) -> Series
 
fn new_from_index(&self, _index: usize, _length: usize) -> Series
Create a new Series filled with values from the given index.
§Example
use polars_core::prelude::*;
let s = Series::new("a", [0i32, 1, 8]);
let s2 = s.new_from_index(2, 4);
assert_eq!(Vec::from(s2.i32().unwrap()), &[Some(8), Some(8), Some(8), Some(8)])fn cast( &self, _data_type: &DataType, options: CastOptions ) -> Result<Series, PolarsError>
sourcefn get(&self, _index: usize) -> Result<AnyValue<'_>, PolarsError>
 
fn get(&self, _index: usize) -> Result<AnyValue<'_>, PolarsError>
Get a single value by index. Don’t use this operation for loops as a runtime cast is needed for every iteration.
sourcefn null_count(&self) -> usize
 
fn null_count(&self) -> usize
Count the null values.
sourcefn has_validity(&self) -> bool
 
fn has_validity(&self) -> bool
Return if any the chunks in this [ChunkedArray] have a validity bitmap.
no bitmap means no null values.
sourcefn is_null(&self) -> ChunkedArray<BooleanType>
 
fn is_null(&self) -> ChunkedArray<BooleanType>
Get a mask of the null values.
sourcefn is_not_null(&self) -> ChunkedArray<BooleanType>
 
fn is_not_null(&self) -> ChunkedArray<BooleanType>
Get a mask of the non-null values.
sourcefn shift(&self, _periods: i64) -> Series
 
fn shift(&self, _periods: i64) -> Series
Shift the values by a given period and fill the parts that will be empty due to this operation
with Nones.
NOTE: If you want to fill the Nones with a value use the
shift operation on ChunkedArray<T>.
§Example
fn example() -> PolarsResult<()> {
    let s = Series::new("series", &[1, 2, 3]);
    let shifted = s.shift(1);
    assert_eq!(Vec::from(shifted.i32()?), &[None, Some(1), Some(2)]);
    let shifted = s.shift(-1);
    assert_eq!(Vec::from(shifted.i32()?), &[Some(2), Some(3), None]);
    let shifted = s.shift(2);
    assert_eq!(Vec::from(shifted.i32()?), &[None, None, Some(1)]);
    Ok(())
}
example();sourcefn clone_inner(&self) -> Arc<dyn SeriesTrait>
 
fn clone_inner(&self) -> Arc<dyn SeriesTrait>
Clone inner ChunkedArray and wrap in a new Arc
Provided Methods§
fn bitand(&self, _other: &Series) -> Result<Series, PolarsError>
fn bitor(&self, _other: &Series) -> Result<Series, PolarsError>
fn bitxor(&self, _other: &Series) -> Result<Series, PolarsError>
sourcefn shrink_to_fit(&mut self)
 
fn shrink_to_fit(&mut self)
Shrink the capacity of this array to fit its length.
sourcefn limit(&self, num_elements: usize) -> Series
 
fn limit(&self, num_elements: usize) -> Series
Take num_elements from the top as a zero copy view.
sourcefn drop_nulls(&self) -> Series
 
fn drop_nulls(&self) -> Series
Drop all null values and return a new Series.
sourcefn mean(&self) -> Option<f64>
 
fn mean(&self) -> Option<f64>
Returns the mean value in the array Returns an option because the array is nullable.
sourcefn std(&self, _ddof: u8) -> Option<f64>
 
fn std(&self, _ddof: u8) -> Option<f64>
Returns the std value in the array Returns an option because the array is nullable.
sourcefn var(&self, _ddof: u8) -> Option<f64>
 
fn var(&self, _ddof: u8) -> Option<f64>
Returns the var value in the array Returns an option because the array is nullable.
sourcefn median(&self) -> Option<f64>
 
fn median(&self) -> Option<f64>
Returns the median value in the array Returns an option because the array is nullable.
sourceunsafe fn get_unchecked(&self, _index: usize) -> AnyValue<'_>
 
unsafe fn get_unchecked(&self, _index: usize) -> AnyValue<'_>
Get a single value by index. Don’t use this operation for loops as a runtime cast is needed for every iteration.
This may refer to physical types
§Safety
Does not do any bounds checking
fn sort_with(&self, _options: SortOptions) -> Result<Series, PolarsError>
sourcefn arg_sort(&self, options: SortOptions) -> ChunkedArray<UInt32Type>
 
fn arg_sort(&self, options: SortOptions) -> ChunkedArray<UInt32Type>
Retrieve the indexes needed for a sort.
sourcefn unique(&self) -> Result<Series, PolarsError>
 
fn unique(&self) -> Result<Series, PolarsError>
Get unique values in the Series.
sourcefn n_unique(&self) -> Result<usize, PolarsError>
 
fn n_unique(&self) -> Result<usize, PolarsError>
Get unique values in the Series.
sourcefn arg_unique(&self) -> Result<ChunkedArray<UInt32Type>, PolarsError>
 
fn arg_unique(&self) -> Result<ChunkedArray<UInt32Type>, PolarsError>
Get first indexes of unique values.
sourcefn as_single_ptr(&mut self) -> Result<usize, PolarsError>
 
fn as_single_ptr(&mut self) -> Result<usize, PolarsError>
Rechunk and return a pointer to the start of the Series. Only implemented for numeric types
sourcefn sum_reduce(&self) -> Result<Scalar, PolarsError>
 
fn sum_reduce(&self) -> Result<Scalar, PolarsError>
Get the sum of the Series as a new Scalar.
If the DataType is one of {Int8, UInt8, Int16, UInt16} the Series is
first cast to Int64 to prevent overflow issues.
sourcefn max_reduce(&self) -> Result<Scalar, PolarsError>
 
fn max_reduce(&self) -> Result<Scalar, PolarsError>
Get the max of the Series as a new Series of length 1.
sourcefn min_reduce(&self) -> Result<Scalar, PolarsError>
 
fn min_reduce(&self) -> Result<Scalar, PolarsError>
Get the min of the Series as a new Series of length 1.
sourcefn median_reduce(&self) -> Result<Scalar, PolarsError>
 
fn median_reduce(&self) -> Result<Scalar, PolarsError>
Get the median of the Series as a new Series of length 1.
sourcefn var_reduce(&self, _ddof: u8) -> Result<Scalar, PolarsError>
 
fn var_reduce(&self, _ddof: u8) -> Result<Scalar, PolarsError>
Get the variance of the Series as a new Series of length 1.
sourcefn std_reduce(&self, _ddof: u8) -> Result<Scalar, PolarsError>
 
fn std_reduce(&self, _ddof: u8) -> Result<Scalar, PolarsError>
Get the standard deviation of the Series as a new Series of length 1.
sourcefn quantile_reduce(
    &self,
    _quantile: f64,
    _interpol: QuantileInterpolOptions
) -> Result<Scalar, PolarsError>
 
fn quantile_reduce( &self, _quantile: f64, _interpol: QuantileInterpolOptions ) -> Result<Scalar, PolarsError>
Get the quantile of the ChunkedArray as a new Series of length 1.
sourcefn get_object(&self, _index: usize) -> Option<&(dyn PolarsObjectSafe + 'static)>
 Available on crate feature object only.
fn get_object(&self, _index: usize) -> Option<&(dyn PolarsObjectSafe + 'static)>
object only.Get the value at this index as a downcastable Any trait ref.
sourceunsafe fn get_object_chunked_unchecked(
    &self,
    _chunk: usize,
    _index: usize
) -> Option<&(dyn PolarsObjectSafe + 'static)>
 Available on crate feature object only.
unsafe fn get_object_chunked_unchecked( &self, _chunk: usize, _index: usize ) -> Option<&(dyn PolarsObjectSafe + 'static)>
object only.Get the value at this index as a downcastable Any trait ref.
§Safety
This function doesn’t do any bound checks.
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Get a hold to self as Any trait reference.
Only implemented for ObjectType
fn checked_div(&self, _rhs: &Series) -> Result<Series, PolarsError>
checked_arithmetic only.sourcefn rolling_map(
    &self,
    _f: &dyn Fn(&Series) -> Series,
    _options: RollingOptionsFixedWindow
) -> Result<Series, PolarsError>
 Available on crate feature rolling_window only.
fn rolling_map( &self, _f: &dyn Fn(&Series) -> Series, _options: RollingOptionsFixedWindow ) -> Result<Series, PolarsError>
rolling_window only.Apply a custom function over a rolling/ moving window of the array. This has quite some dynamic dispatch, so prefer rolling_min, max, mean, sum over this.