pub trait SeriesTrait:
Send
+ Sync
+ PrivateSeries
+ PrivateSeriesNumeric {
Show 64 methods
// Required methods
fn rename(&mut self, name: PlSmallStr);
fn chunk_lengths(&self) -> ChunkLenIter<'_>;
fn name(&self) -> &PlSmallStr;
fn chunks(&self) -> &Vec<ArrayRef>;
unsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef>;
fn slice(&self, _offset: i64, _length: usize) -> Series;
fn split_at(&self, _offset: i64) -> (Series, Series);
fn filter(&self, _filter: &BooleanChunked) -> PolarsResult<Series>;
fn take(&self, _indices: &IdxCa) -> PolarsResult<Series>;
unsafe fn take_unchecked(&self, _idx: &IdxCa) -> Series;
fn take_slice(&self, _indices: &[IdxSize]) -> PolarsResult<Series>;
unsafe fn take_slice_unchecked(&self, _idx: &[IdxSize]) -> Series;
fn len(&self) -> usize;
fn rechunk(&self) -> Series;
fn new_from_index(&self, _index: usize, _length: usize) -> Series;
fn cast(
&self,
_dtype: &DataType,
options: CastOptions,
) -> PolarsResult<Series>;
unsafe fn get_unchecked(&self, _index: usize) -> AnyValue<'_>;
fn null_count(&self) -> usize;
fn has_nulls(&self) -> bool;
fn is_null(&self) -> BooleanChunked;
fn is_not_null(&self) -> BooleanChunked;
fn reverse(&self) -> Series;
fn shift(&self, _periods: i64) -> Series;
fn clone_inner(&self) -> Arc<dyn SeriesTrait>;
fn as_any(&self) -> &dyn Any;
// Provided methods
fn get_metadata(&self) -> Option<RwLockReadGuard<'_, dyn MetadataTrait>> { ... }
fn boxed_metadata<'a>(&'a self) -> Option<Box<dyn MetadataTrait + 'a>> { ... }
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 rechunk_validity(&self) -> Option<Bitmap> { ... }
fn drop_nulls(&self) -> Series { ... }
fn _sum_as_f64(&self) -> f64 { ... }
fn mean(&self) -> Option<f64> { ... }
fn std(&self, _ddof: u8) -> Option<f64> { ... }
fn var(&self, _ddof: u8) -> Option<f64> { ... }
fn median(&self) -> Option<f64> { ... }
fn get(&self, index: usize) -> PolarsResult<AnyValue<'_>> { ... }
fn sort_with(&self, _options: SortOptions) -> PolarsResult<Series> { ... }
fn arg_sort(&self, options: SortOptions) -> IdxCa { ... }
fn unique(&self) -> PolarsResult<Series> { ... }
fn n_unique(&self) -> PolarsResult<usize> { ... }
fn arg_unique(&self) -> PolarsResult<IdxCa> { ... }
fn as_single_ptr(&mut self) -> PolarsResult<usize> { ... }
fn sum_reduce(&self) -> PolarsResult<Scalar> { ... }
fn max_reduce(&self) -> PolarsResult<Scalar> { ... }
fn min_reduce(&self) -> PolarsResult<Scalar> { ... }
fn median_reduce(&self) -> PolarsResult<Scalar> { ... }
fn var_reduce(&self, _ddof: u8) -> PolarsResult<Scalar> { ... }
fn std_reduce(&self, _ddof: u8) -> PolarsResult<Scalar> { ... }
fn quantile_reduce(
&self,
_quantile: f64,
_method: QuantileMethod,
) -> PolarsResult<Scalar> { ... }
fn and_reduce(&self) -> PolarsResult<Scalar> { ... }
fn or_reduce(&self) -> PolarsResult<Scalar> { ... }
fn xor_reduce(&self) -> PolarsResult<Scalar> { ... }
fn first(&self) -> Scalar { ... }
fn last(&self) -> Scalar { ... }
fn get_object(&self, _index: usize) -> Option<&dyn PolarsObjectSafe> { ... }
unsafe fn get_object_chunked_unchecked(
&self,
_chunk: usize,
_index: usize,
) -> Option<&dyn PolarsObjectSafe> { ... }
fn as_any_mut(&mut self) -> &mut dyn Any { ... }
fn checked_div(&self, _rhs: &Series) -> PolarsResult<Series> { ... }
fn rolling_map(
&self,
_f: &dyn Fn(&Series) -> Series,
_options: RollingOptionsFixedWindow,
) -> PolarsResult<Series> { ... }
}
Required Methods§
Sourcefn rename(&mut self, name: PlSmallStr)
fn rename(&mut self, name: PlSmallStr)
Rename the Series.
Sourcefn chunk_lengths(&self) -> ChunkLenIter<'_>
fn chunk_lengths(&self) -> ChunkLenIter<'_>
Get the lengths of the underlying chunks
Sourcefn name(&self) -> &PlSmallStr
fn name(&self) -> &PlSmallStr
Name of series.
Sourceunsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef>
unsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef>
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 split_at(&self, _offset: i64) -> (Series, Series)
fn split_at(&self, _offset: i64) -> (Series, 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: &BooleanChunked) -> PolarsResult<Series>
fn filter(&self, _filter: &BooleanChunked) -> PolarsResult<Series>
Filter by boolean mask. This operation clones data.
Sourcefn take(&self, _indices: &IdxCa) -> PolarsResult<Series>
fn take(&self, _indices: &IdxCa) -> PolarsResult<Series>
Take from self
at the indexes given by idx
.
Null values in idx
because null values in the output array.
This operation is clone.
Sourceunsafe fn take_unchecked(&self, _idx: &IdxCa) -> Series
unsafe fn take_unchecked(&self, _idx: &IdxCa) -> Series
Take from self
at the indexes given by idx
.
Null values in idx
because null values in the output array.
§Safety
This doesn’t check any bounds.
Sourcefn take_slice(&self, _indices: &[IdxSize]) -> PolarsResult<Series>
fn take_slice(&self, _indices: &[IdxSize]) -> PolarsResult<Series>
Take from self
at the indexes given by idx
.
This operation is clone.
Sourceunsafe fn take_slice_unchecked(&self, _idx: &[IdxSize]) -> Series
unsafe fn take_slice_unchecked(&self, _idx: &[IdxSize]) -> 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".into(), [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, _dtype: &DataType, options: CastOptions) -> PolarsResult<Series>
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
Sourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
Count the null values.
Sourcefn has_nulls(&self) -> bool
fn has_nulls(&self) -> bool
Return if any the chunks in this ChunkedArray
have nulls.
Sourcefn is_null(&self) -> BooleanChunked
fn is_null(&self) -> BooleanChunked
Get a mask of the null values.
Sourcefn is_not_null(&self) -> BooleanChunked
fn is_not_null(&self) -> BooleanChunked
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".into(), &[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 get_metadata(&self) -> Option<RwLockReadGuard<'_, dyn MetadataTrait>>
fn boxed_metadata<'a>(&'a self) -> Option<Box<dyn MetadataTrait + 'a>>
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.
fn rechunk_validity(&self) -> Option<Bitmap>
Sourcefn drop_nulls(&self) -> Series
fn drop_nulls(&self) -> Series
Drop all null values and return a new Series.
Sourcefn _sum_as_f64(&self) -> f64
fn _sum_as_f64(&self) -> f64
Returns the sum of the array as an f64.
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.
Sourcefn get(&self, index: usize) -> PolarsResult<AnyValue<'_>>
fn get(&self, index: usize) -> PolarsResult<AnyValue<'_>>
Get a single value by index. Don’t use this operation for loops as a runtime cast is needed for every iteration.
fn sort_with(&self, _options: SortOptions) -> PolarsResult<Series>
Sourcefn arg_sort(&self, options: SortOptions) -> IdxCa
fn arg_sort(&self, options: SortOptions) -> IdxCa
Retrieve the indexes needed for a sort.
Sourcefn unique(&self) -> PolarsResult<Series>
fn unique(&self) -> PolarsResult<Series>
Get unique values in the Series.
Sourcefn n_unique(&self) -> PolarsResult<usize>
fn n_unique(&self) -> PolarsResult<usize>
Get unique values in the Series.
A null
value also counts as a unique value.
Sourcefn arg_unique(&self) -> PolarsResult<IdxCa>
fn arg_unique(&self) -> PolarsResult<IdxCa>
Get first indexes of unique values.
Sourcefn as_single_ptr(&mut self) -> PolarsResult<usize>
fn as_single_ptr(&mut self) -> PolarsResult<usize>
Rechunk and return a pointer to the start of the Series. Only implemented for numeric types
Sourcefn sum_reduce(&self) -> PolarsResult<Scalar>
fn sum_reduce(&self) -> PolarsResult<Scalar>
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) -> PolarsResult<Scalar>
fn max_reduce(&self) -> PolarsResult<Scalar>
Get the max of the Series as a new Series of length 1.
Sourcefn min_reduce(&self) -> PolarsResult<Scalar>
fn min_reduce(&self) -> PolarsResult<Scalar>
Get the min of the Series as a new Series of length 1.
Sourcefn median_reduce(&self) -> PolarsResult<Scalar>
fn median_reduce(&self) -> PolarsResult<Scalar>
Get the median of the Series as a new Series of length 1.
Sourcefn var_reduce(&self, _ddof: u8) -> PolarsResult<Scalar>
fn var_reduce(&self, _ddof: u8) -> PolarsResult<Scalar>
Get the variance of the Series as a new Series of length 1.
Sourcefn std_reduce(&self, _ddof: u8) -> PolarsResult<Scalar>
fn std_reduce(&self, _ddof: u8) -> PolarsResult<Scalar>
Get the standard deviation of the Series as a new Series of length 1.
Sourcefn quantile_reduce(
&self,
_quantile: f64,
_method: QuantileMethod,
) -> PolarsResult<Scalar>
fn quantile_reduce( &self, _quantile: f64, _method: QuantileMethod, ) -> PolarsResult<Scalar>
Get the quantile of the ChunkedArray as a new Series of length 1.
Sourcefn and_reduce(&self) -> PolarsResult<Scalar>
fn and_reduce(&self) -> PolarsResult<Scalar>
Get the bitwise AND of the Series as a new Series of length 1,
Sourcefn or_reduce(&self) -> PolarsResult<Scalar>
fn or_reduce(&self) -> PolarsResult<Scalar>
Get the bitwise OR of the Series as a new Series of length 1,
Sourcefn xor_reduce(&self) -> PolarsResult<Scalar>
fn xor_reduce(&self) -> PolarsResult<Scalar>
Get the bitwise XOR of the Series as a new Series of length 1,
Sourcefn first(&self) -> Scalar
fn first(&self) -> Scalar
Get the first element of the Series
as a Scalar
If the Series
is empty, a Scalar
with a AnyValue::Null
is returned.
Sourcefn last(&self) -> Scalar
fn last(&self) -> Scalar
Get the last element of the Series
as a Scalar
If the Series
is empty, a Scalar
with a AnyValue::Null
is returned.
Sourcefn get_object(&self, _index: usize) -> Option<&dyn PolarsObjectSafe>
Available on crate feature object
only.
fn get_object(&self, _index: usize) -> Option<&dyn PolarsObjectSafe>
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>
Available on crate feature object
only.
unsafe fn get_object_chunked_unchecked( &self, _chunk: usize, _index: usize, ) -> Option<&dyn PolarsObjectSafe>
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
fn as_any_mut(&mut self) -> &mut dyn Any
Get a hold to self as Any
trait reference.
Only implemented for ObjectType
fn checked_div(&self, _rhs: &Series) -> PolarsResult<Series>
checked_arithmetic
only.Sourcefn rolling_map(
&self,
_f: &dyn Fn(&Series) -> Series,
_options: RollingOptionsFixedWindow,
) -> PolarsResult<Series>
Available on crate feature rolling_window
only.
fn rolling_map( &self, _f: &dyn Fn(&Series) -> Series, _options: RollingOptionsFixedWindow, ) -> PolarsResult<Series>
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.