1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
use crate::prelude::*;
use crate::series::ops::NullBehavior;

impl Series {
    #[cfg_attr(docsrs, doc(cfg(feature = "diff")))]
    pub fn diff(&self, n: usize, null_behavior: NullBehavior) -> Series {
        match null_behavior {
            NullBehavior::Ignore => self - &self.shift(n as i64),
            NullBehavior::Drop => {
                let len = self.len() - n;
                &self.slice(n as i64, len) - &self.slice(0, len)
            }
        }
    }
}