pub fn replace_at_idx<S: IntoSeries>(&mut self, idx: usize, new_col: S) -> Result<&mut Self> {
        let mut new_column = new_col.into_series();
        self.has_column(new_column.name())?;
        if new_column.len() != self.height() {
            return Err(PolarsError::ShapeMisMatch(
                format!("Cannot replace Series at index {}. The shape of Series {} does not match that of the DataFrame {}",
                idx, new_column.len(), self.height()
                ).into()));
        };
        if idx >= self.width() {
            return Err(PolarsError::OutOfBounds(
                format!(
                    "Column index: {} outside of DataFrame with {} columns",
                    idx,
                    self.width()
                )
                .into(),
            ));
        }
        let old_col = &mut self.columns[idx];
        mem::swap(old_col, &mut new_column);
        Ok(self)
    }
/// Replace column at index `idx` with a series.
///
/// # Example
///
/// ```rust
/// use polars::prelude::*;
/// let s0 = Series::new("foo", &["ham", "spam", "egg"]);
/// let s1 = Series::new("ascii", &[70, 79, 79]);
/// let mut df = DataFrame::new(vec![s0, s1]).unwrap();
///
/// // Add 32 to get lowercase ascii values
/// df.replace_at_idx(1, df.select_at_idx(1).unwrap() + 32);
/// ```
Replace column at index `idx` with a series.
Replace column at index ` idx ` with a series .
pub fn replace_at_idx<S: IntoSeries>(&mut self, idx: usize, new_col: S) -> Result<&mut Self> {
        let mut new_column = new_col.into_series();
        self.has_column(new_column.name())?;
        if new_column.len() != self.height() {
            return Err(PolarsError::ShapeMisMatch(
                format!("Cannot replace Series at index {}. The shape of Series {} does not match that of the DataFrame {}",
                idx, new_column.len(), self.height()
                ).into()));
        };
        if idx >= self.width() {
            return Err(PolarsError::OutOfBounds(
                format!(
                    "Column index: {} outside of DataFrame with {} columns",
                    idx,
                    self.width()
                )
                .into(),
            ));
        }
        let old_col = &mut self.columns[idx];
        mem::swap(old_col, &mut new_column);
        Ok(self)
    }
pub fn replace_at_idx < S : IntoSeries > ( & mut self , idx : usize , new_col : S ) -> Result < & mut Self > { let mut new_column = new_col . into_series ( ) ; self . has_column ( new_column . name ( ) ) ? ; if new_column . len ( ) != self . height ( ) { return Err ( PolarsError :: ShapeMisMatch ( format ! ( " " idx new_column len ( ) self height ( ) ) . into ( ) ) ) ; } ; if idx >= self . width ( ) { return Err ( PolarsError :: OutOfBounds ( format ! ( " " idx self width ( ) ) . into ( ) , ) ) ; } let old_col = & mut self . columns [ idx ] ; mem :: swap ( old_col , & mut new_column ) ; Ok ( self ) }
Replace column at index `idx` with a series.
Replace column at index ` idx ` with a series .
&mut self
idx
usize
new_col
S
&mut self
idx
usize
new_col
S
example


Add 32 to get lowercase ascii values
df.replace_at_idx(1, df.select_at_idx(1).unwrap() + 32);
```
Add 32 to get lowercase ascii values df . replace_at_idx ( 1 df . select_at_idx ( 1 ) . unwrap () + 32 ) ; ` ` `