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 // TODO: Use `from_any_values_and_dtype` here instead of casting afterwards
7 let s = Series::from_any_values(PlSmallStr::EMPTY, &[value], true).unwrap();
8 let s = s.cast(self.dtype())?;
9 let to_append = s.new_from_index(0, n);
10
11 let mut out = self.clone();
12 out.append(&to_append)?;
13 Ok(out)
14 }
15}