[][src]Trait polars::series::SeriesTrait

pub trait SeriesTrait: Send + Sync + PrivateSeries {
    pub fn rename(&mut self, name: &str);
pub fn sample_n(&self, n: usize, with_replacement: bool) -> Result<Series>;
pub fn sample_frac(
        &self,
        frac: f64,
        with_replacement: bool
    ) -> Result<Series>; pub fn array_data(&self) -> Vec<ArrayDataRef> { ... }
pub fn chunk_lengths(&self) -> &Vec<usize> { ... }
pub fn name(&self) -> &str { ... }
pub fn field(&self) -> &Field { ... }
pub fn dtype(&self) -> &ArrowDataType { ... }
pub fn chunks(&self) -> &Vec<ArrayRef> { ... }
pub fn n_chunks(&self) -> usize { ... }
pub fn i8(&self) -> Result<&Int8Chunked> { ... }
pub fn i16(&self) -> Result<&Int16Chunked> { ... }
pub fn i32(&self) -> Result<&Int32Chunked> { ... }
pub fn i64(&self) -> Result<&Int64Chunked> { ... }
pub fn f32(&self) -> Result<&Float32Chunked> { ... }
pub fn f64(&self) -> Result<&Float64Chunked> { ... }
pub fn u8(&self) -> Result<&UInt8Chunked> { ... }
pub fn u16(&self) -> Result<&UInt16Chunked> { ... }
pub fn u32(&self) -> Result<&UInt32Chunked> { ... }
pub fn u64(&self) -> Result<&UInt64Chunked> { ... }
pub fn bool(&self) -> Result<&BooleanChunked> { ... }
pub fn utf8(&self) -> Result<&Utf8Chunked> { ... }
pub fn date32(&self) -> Result<&Date32Chunked> { ... }
pub fn date64(&self) -> Result<&Date64Chunked> { ... }
pub fn time64_nanosecond(&self) -> Result<&Time64NanosecondChunked> { ... }
pub fn duration_nanosecond(&self) -> Result<&DurationNanosecondChunked> { ... }
pub fn duration_millisecond(&self) -> Result<&DurationMillisecondChunked> { ... }
pub fn list(&self) -> Result<&ListChunked> { ... }
pub fn append_array(&mut self, _other: ArrayRef) -> Result<()> { ... }
pub fn limit(&self, num_elements: usize) -> Result<Series> { ... }
pub fn slice(&self, _offset: usize, _length: usize) -> Result<Series> { ... }
pub fn append(&mut self, _other: &Series) -> Result<()> { ... }
pub fn filter(&self, _filter: &BooleanChunked) -> Result<Series> { ... }
pub fn take_iter(
        &self,
        _iter: &mut dyn Iterator<Item = usize>,
        _capacity: Option<usize>
    ) -> Series { ... }
pub unsafe fn take_iter_unchecked(
        &self,
        _iter: &mut dyn Iterator<Item = usize>,
        _capacity: Option<usize>
    ) -> Series { ... }
pub unsafe fn take_from_single_chunked(
        &self,
        _idx: &UInt32Chunked
    ) -> Result<Series> { ... }
pub unsafe fn take_opt_iter_unchecked(
        &self,
        _iter: &mut dyn Iterator<Item = Option<usize>>,
        _capacity: Option<usize>
    ) -> Series { ... }
pub fn take_opt_iter(
        &self,
        _iter: &mut dyn Iterator<Item = Option<usize>>,
        _capacity: Option<usize>
    ) -> Series { ... }
pub fn take(&self, indices: &dyn AsTakeIndex) -> Series { ... }
pub fn len(&self) -> usize { ... }
pub fn is_empty(&self) -> bool { ... }
pub fn rechunk(&self, _chunk_lengths: Option<&[usize]>) -> Result<Series> { ... }
pub fn head(&self, _length: Option<usize>) -> Series { ... }
pub fn tail(&self, _length: Option<usize>) -> Series { ... }
pub fn drop_nulls(&self) -> Series { ... }
pub fn expand_at_index(&self, _index: usize, _length: usize) -> Series { ... }
pub fn cast_with_arrow_datatype(
        &self,
        _data_type: &ArrowDataType
    ) -> Result<Series> { ... }
pub fn to_dummies(&self) -> Result<DataFrame> { ... }
pub fn value_counts(&self) -> Result<DataFrame> { ... }
pub fn get(&self, _index: usize) -> AnyType<'_> { ... }
pub fn sort_in_place(&mut self, _reverse: bool) { ... }
pub fn sort(&self, _reverse: bool) -> Series { ... }
pub fn argsort(&self, _reverse: bool) -> Vec<usize> { ... }
pub fn null_count(&self) -> usize { ... }
pub fn unique(&self) -> Result<Series> { ... }
pub fn n_unique(&self) -> Result<usize> { ... }
pub fn arg_unique(&self) -> Result<Vec<usize>> { ... }
pub fn arg_true(&self) -> Result<UInt32Chunked> { ... }
pub fn is_null(&self) -> BooleanChunked { ... }
pub fn is_not_null(&self) -> BooleanChunked { ... }
pub fn is_unique(&self) -> Result<BooleanChunked> { ... }
pub fn is_duplicated(&self) -> Result<BooleanChunked> { ... }
pub fn null_bits(&self) -> Vec<(usize, Option<Buffer>)> { ... }
pub fn reverse(&self) -> Series { ... }
pub fn as_single_ptr(&mut self) -> Result<usize> { ... }
pub fn shift(&self, _periods: i32) -> Result<Series> { ... }
pub fn fill_none(&self, _strategy: FillNoneStrategy) -> Result<Series> { ... }
pub fn zip_with(
        &self,
        _mask: &BooleanChunked,
        _other: &Series
    ) -> Result<Series> { ... }
pub fn sum_as_series(&self) -> Series { ... }
pub fn max_as_series(&self) -> Series { ... }
pub fn min_as_series(&self) -> Series { ... }
pub fn mean_as_series(&self) -> Series { ... }
pub fn median_as_series(&self) -> Series { ... }
pub fn var_as_series(&self) -> Series { ... }
pub fn std_as_series(&self) -> Series { ... }
pub fn quantile_as_series(&self, _quantile: f64) -> Result<Series> { ... }
pub fn rolling_mean(
        &self,
        _window_size: usize,
        _weight: Option<&[f64]>,
        _ignore_null: bool
    ) -> Result<Series> { ... }
pub fn rolling_sum(
        &self,
        _window_size: usize,
        _weight: Option<&[f64]>,
        _ignore_null: bool
    ) -> Result<Series> { ... }
pub fn rolling_min(
        &self,
        _window_size: usize,
        _weight: Option<&[f64]>,
        _ignore_null: bool
    ) -> Result<Series> { ... }
pub fn rolling_max(
        &self,
        _window_size: usize,
        _weight: Option<&[f64]>,
        _ignore_null: bool
    ) -> Result<Series> { ... }
pub fn fmt_list(&self) -> String { ... }
pub fn hour(&self) -> Result<Series> { ... }
pub fn minute(&self) -> Result<Series> { ... }
pub fn second(&self) -> Result<Series> { ... }
pub fn nanosecond(&self) -> Result<Series> { ... }
pub fn day(&self) -> Result<Series> { ... }
pub fn ordinal_day(&self) -> Result<Series> { ... }
pub fn month(&self) -> Result<Series> { ... }
pub fn year(&self) -> Result<Series> { ... }
pub fn clone_inner(&self) -> Arc<dyn SeriesTrait> { ... }
pub fn get_as_any(&self, _index: usize) -> &dyn Any { ... } }

Required methods

pub fn rename(&mut self, name: &str)[src]

Rename the Series.

pub fn sample_n(&self, n: usize, with_replacement: bool) -> Result<Series>[src]

This is supported on crate feature random only.

Sample n datapoints from this Series.

pub fn sample_frac(&self, frac: f64, with_replacement: bool) -> Result<Series>[src]

This is supported on crate feature random only.

Sample a fraction between 0.0-1.0 of this ChunkedArray.

Loading content...

Provided methods

pub fn array_data(&self) -> Vec<ArrayDataRef>[src]

Get Arrow ArrayData

pub fn chunk_lengths(&self) -> &Vec<usize>[src]

Get the lengths of the underlying chunks

pub fn name(&self) -> &str[src]

Name of series.

pub fn field(&self) -> &Field[src]

Get field (used in schema)

pub fn dtype(&self) -> &ArrowDataType[src]

Get datatype of series.

pub fn chunks(&self) -> &Vec<ArrayRef>[src]

Underlying chunks.

pub fn n_chunks(&self) -> usize[src]

Number of chunks in this Series

pub fn i8(&self) -> Result<&Int8Chunked>[src]

Unpack to ChunkedArray of dtype i8

pub fn i16(&self) -> Result<&Int16Chunked>[src]

Unpack to ChunkedArray i16

pub fn i32(&self) -> Result<&Int32Chunked>[src]

Unpack to ChunkedArray

let s: Series = [1, 2, 3].iter().collect();
let s_squared: Series = s.i32()
    .unwrap()
    .into_iter()
    .map(|opt_v| {
        match opt_v {
            Some(v) => Some(v * v),
            None => None, // null value
        }
}).collect();

pub fn i64(&self) -> Result<&Int64Chunked>[src]

Unpack to ChunkedArray of dtype i64

pub fn f32(&self) -> Result<&Float32Chunked>[src]

Unpack to ChunkedArray of dtype f32

pub fn f64(&self) -> Result<&Float64Chunked>[src]

Unpack to ChunkedArray of dtype f64

pub fn u8(&self) -> Result<&UInt8Chunked>[src]

Unpack to ChunkedArray of dtype u8

pub fn u16(&self) -> Result<&UInt16Chunked>[src]

Unpack to ChunkedArray of dtype u16

pub fn u32(&self) -> Result<&UInt32Chunked>[src]

Unpack to ChunkedArray of dtype u32

pub fn u64(&self) -> Result<&UInt64Chunked>[src]

Unpack to ChunkedArray of dtype u64

pub fn bool(&self) -> Result<&BooleanChunked>[src]

Unpack to ChunkedArray of dtype bool

pub fn utf8(&self) -> Result<&Utf8Chunked>[src]

Unpack to ChunkedArray of dtype utf8

pub fn date32(&self) -> Result<&Date32Chunked>[src]

Unpack to ChunkedArray of dtype date32

pub fn date64(&self) -> Result<&Date64Chunked>[src]

Unpack to ChunkedArray of dtype date64

pub fn time64_nanosecond(&self) -> Result<&Time64NanosecondChunked>[src]

Unpack to ChunkedArray of dtype time64_nanosecond

pub fn duration_nanosecond(&self) -> Result<&DurationNanosecondChunked>[src]

Unpack to ChunkedArray of dtype duration_nanosecond

pub fn duration_millisecond(&self) -> Result<&DurationMillisecondChunked>[src]

Unpack to ChunkedArray of dtype duration_millisecond

pub fn list(&self) -> Result<&ListChunked>[src]

Unpack to ChunkedArray of dtype list

pub fn append_array(&mut self, _other: ArrayRef) -> Result<()>[src]

Append Arrow array of same dtype to this Series.

pub fn limit(&self, num_elements: usize) -> Result<Series>[src]

Take num_elements from the top as a zero copy view.

pub fn slice(&self, _offset: usize, _length: usize) -> Result<Series>[src]

Get a zero copy view of the data.

pub fn append(&mut self, _other: &Series) -> Result<()>[src]

Append a Series of the same type in place.

pub fn filter(&self, _filter: &BooleanChunked) -> Result<Series>[src]

Filter by boolean mask. This operation clones data.

pub fn take_iter(
    &self,
    _iter: &mut dyn Iterator<Item = usize>,
    _capacity: Option<usize>
) -> Series
[src]

Take by index from an iterator. This operation clones the data.

Safety

Out of bounds access doesn't Error but will return a Null value

pub unsafe fn take_iter_unchecked(
    &self,
    _iter: &mut dyn Iterator<Item = usize>,
    _capacity: Option<usize>
) -> Series
[src]

Take by index from an iterator. This operation clones the data.

Safety

This doesn't check any bounds or null validity.

pub unsafe fn take_from_single_chunked(
    &self,
    _idx: &UInt32Chunked
) -> Result<Series>
[src]

Take by index if ChunkedArray contains a single chunk.

Safety

This doesn't check any bounds. Null validity is checked.

pub unsafe fn take_opt_iter_unchecked(
    &self,
    _iter: &mut dyn Iterator<Item = Option<usize>>,
    _capacity: Option<usize>
) -> Series
[src]

Take by index from an iterator. This operation clones the data.

Safety

This doesn't check any bounds or null validity.

pub fn take_opt_iter(
    &self,
    _iter: &mut dyn Iterator<Item = Option<usize>>,
    _capacity: Option<usize>
) -> Series
[src]

Take by index from an iterator. This operation clones the data.

Safety

Out of bounds access doesn't Error but will return a Null value

pub fn take(&self, indices: &dyn AsTakeIndex) -> Series[src]

Take by index. This operation is clone.

Safety

Out of bounds access doesn't Error but will return a Null value

pub fn len(&self) -> usize[src]

Get length of series.

pub fn is_empty(&self) -> bool[src]

Check if Series is empty.

pub fn rechunk(&self, _chunk_lengths: Option<&[usize]>) -> Result<Series>[src]

Aggregate all chunks to a contiguous array of memory.

pub fn head(&self, _length: Option<usize>) -> Series[src]

Get the head of the Series.

pub fn tail(&self, _length: Option<usize>) -> Series[src]

Get the tail of the Series.

pub fn drop_nulls(&self) -> Series[src]

Drop all null values and return a new Series.

pub fn expand_at_index(&self, _index: usize, _length: usize) -> Series[src]

Create a new Series filled with values at that index.

Example

use polars::prelude::*;
let s = Series::new("a", [0i32, 1, 8]);
let expanded = s.expand_at_index(2, 4);
assert_eq!(Vec::from(expanded.i32().unwrap()), &[Some(8), Some(8), Some(8), Some(8)])

pub fn cast_with_arrow_datatype(
    &self,
    _data_type: &ArrowDataType
) -> Result<Series>
[src]

pub fn to_dummies(&self) -> Result<DataFrame>[src]

Create dummy variables. See DataFrame

pub fn value_counts(&self) -> Result<DataFrame>[src]

pub fn get(&self, _index: usize) -> AnyType<'_>[src]

Get a single value by index. Don't use this operation for loops as a runtime cast is needed for every iteration.

pub fn sort_in_place(&mut self, _reverse: bool)[src]

Sort in place.

pub fn sort(&self, _reverse: bool) -> Series[src]

pub fn argsort(&self, _reverse: bool) -> Vec<usize>[src]

Retrieve the indexes needed for a sort.

pub fn null_count(&self) -> usize[src]

Count the null values.

pub fn unique(&self) -> Result<Series>[src]

Get unique values in the Series.

pub fn n_unique(&self) -> Result<usize>[src]

Get unique values in the Series.

pub fn arg_unique(&self) -> Result<Vec<usize>>[src]

Get first indexes of unique values.

pub fn arg_true(&self) -> Result<UInt32Chunked>[src]

Get indexes that evaluate true

pub fn is_null(&self) -> BooleanChunked[src]

Get a mask of the null values.

pub fn is_not_null(&self) -> BooleanChunked[src]

Get a mask of the non-null values.

pub fn is_unique(&self) -> Result<BooleanChunked>[src]

Get a mask of all the unique values.

pub fn is_duplicated(&self) -> Result<BooleanChunked>[src]

Get a mask of all the duplicated values.

pub fn null_bits(&self) -> Vec<(usize, Option<Buffer>)>[src]

Get the bits that represent the null values of the underlying ChunkedArray

pub fn reverse(&self) -> Series[src]

return a Series in reversed order

pub fn as_single_ptr(&mut self) -> Result<usize>[src]

Rechunk and return a pointer to the start of the Series. Only implemented for numeric types

pub fn shift(&self, _periods: i32) -> Result<Series>[src]

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() -> Result<()> {
    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();

pub fn fill_none(&self, _strategy: FillNoneStrategy) -> Result<Series>[src]

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)

NOTE: If you want to fill the Nones with a value use the fill_none operation on ChunkedArray<T>.

Example

fn example() -> Result<()> {
    let s = Series::new("some_missing", &[Some(1), None, Some(2)]);

    let filled = s.fill_none(FillNoneStrategy::Forward)?;
    assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);

    let filled = s.fill_none(FillNoneStrategy::Backward)?;
    assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(2), Some(2)]);

    let filled = s.fill_none(FillNoneStrategy::Min)?;
    assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);

    let filled = s.fill_none(FillNoneStrategy::Max)?;
    assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(2), Some(2)]);

    let filled = s.fill_none(FillNoneStrategy::Mean)?;
    assert_eq!(Vec::from(filled.i32()?), &[Some(1), Some(1), Some(2)]);

    Ok(())
}
example();

pub fn zip_with(
    &self,
    _mask: &BooleanChunked,
    _other: &Series
) -> Result<Series>
[src]

Create a new ChunkedArray with values from self where the mask evaluates true and values from other where the mask evaluates false

pub fn sum_as_series(&self) -> Series[src]

Get the sum of the Series as a new Series of length 1.

pub fn max_as_series(&self) -> Series[src]

Get the max of the Series as a new Series of length 1.

pub fn min_as_series(&self) -> Series[src]

Get the min of the Series as a new Series of length 1.

pub fn mean_as_series(&self) -> Series[src]

Get the mean of the Series as a new Series of length 1.

pub fn median_as_series(&self) -> Series[src]

Get the median of the Series as a new Series of length 1.

pub fn var_as_series(&self) -> Series[src]

Get the variance of the Series as a new Series of length 1.

pub fn std_as_series(&self) -> Series[src]

Get the standard deviation of the Series as a new Series of length 1.

pub fn quantile_as_series(&self, _quantile: f64) -> Result<Series>[src]

Get the quantile of the ChunkedArray as a new Series of length 1.

pub fn rolling_mean(
    &self,
    _window_size: usize,
    _weight: Option<&[f64]>,
    _ignore_null: bool
) -> Result<Series>
[src]

Apply a rolling mean to a Series. See: ChunkedArray::rolling_mean.

pub fn rolling_sum(
    &self,
    _window_size: usize,
    _weight: Option<&[f64]>,
    _ignore_null: bool
) -> Result<Series>
[src]

Apply a rolling sum to a Series. See: ChunkedArray::rolling_mean.

pub fn rolling_min(
    &self,
    _window_size: usize,
    _weight: Option<&[f64]>,
    _ignore_null: bool
) -> Result<Series>
[src]

Apply a rolling min to a Series. See: ChunkedArray::rolling_mean.

pub fn rolling_max(
    &self,
    _window_size: usize,
    _weight: Option<&[f64]>,
    _ignore_null: bool
) -> Result<Series>
[src]

Apply a rolling max to a Series. See: ChunkedArray::rolling_mean.

pub fn fmt_list(&self) -> String[src]

pub fn hour(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract hour from underlying NaiveDateTime representation. Returns the hour number from 0 to 23.

pub fn minute(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract minute from underlying NaiveDateTime representation. Returns the minute number from 0 to 59.

pub fn second(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract second from underlying NaiveDateTime representation. Returns the second number from 0 to 59.

pub fn nanosecond(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract second from underlying NaiveDateTime representation. Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second.

pub fn day(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract day from underlying NaiveDateTime representation. Returns the day of month starting from 1.

The return value ranges from 1 to 31. (The last day of month differs by months.)

pub fn ordinal_day(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Returns the day of year starting from 1.

The return value ranges from 1 to 366. (The last day of year differs by years.)

pub fn month(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract month from underlying NaiveDateTime representation. Returns the month number starting from 1.

The return value ranges from 1 to 12.

pub fn year(&self) -> Result<Series>[src]

This is supported on crate feature temporal only.

Extract month from underlying NaiveDateTime representation. Returns the year number in the calendar date.

pub fn clone_inner(&self) -> Arc<dyn SeriesTrait>[src]

Clone inner ChunkedArray and wrap in a new Arc

pub fn get_as_any(&self, _index: usize) -> &dyn Any[src]

Get the value at this index as a downcastable Any trait ref.

Loading content...

Implementations

impl<'a> dyn SeriesTrait + 'a[src]

pub fn unpack<N: 'static>(&self) -> Result<&ChunkedArray<N>> where
    N: PolarsDataType
[src]

Trait Implementations

impl<'a, T> AsRef<ChunkedArray<T>> for dyn SeriesTrait + 'a where
    T: 'static + PolarsDataType
[src]

impl<'a> AsRef<dyn SeriesTrait + 'a> for Series[src]

impl ChunkFull<&'_ (dyn SeriesTrait + '_)> for ListChunked[src]

Implementors

Loading content...