polars_core/series/ops/
extend.rs

1use crate::prelude::*;
2
3impl Series {
4    /// Extend with a constant value.
5    pub fn extend_constant(&self, value: AnyValue, n: usize) -> PolarsResult<Self> {
6        let s =
7            Series::from_any_values_and_dtype(PlSmallStr::EMPTY, &[value], self.dtype(), false)?;
8        let to_append = s.new_from_index(0, n);
9
10        let mut out = self.clone();
11        out.append(&to_append)?;
12        Ok(out)
13    }
14}