shift(periods: number = 1): Series {
    if (!Number.isInteger(periods)) throw new Error('periods must be an integer');

    if (periods === 0) {
      return this.copy();
    } else if (periods < 0) {
      const absPeriods = Math.abs(periods);

      if (absPeriods > this.length) throw new Error('Periods greater than length of Series');

      const values = this.values.slice(absPeriods, this.length)
        .concat(Immutable.Repeat(null, absPeriods).toList());

      return new Series(values, {name: this.name, index: this.index});
    }

    // periods > 0
    if (periods > this.length) throw new Error('Periods greater than length of Series');

    const values = Immutable.Repeat(null, periods).toList()
      .concat(this.values.slice(0, this.length - periods));

    return new Series(values, {name: this.name, index: this.index});
  }
Shift index by desired number of periods

pandas equivalent:s [Series.shift](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.shift.html)

@param {number} periods
 Number of periods to move, can be positive or negative

@returns {Series}

@example
const ds = new Series([1, 2, 3, 4]);

// Returns Series([null, 1, 2, 3]);
ds.shift(1);

// Returns Series([null, null, 1, 2]);
ds.shift(2);

// Returns Series([3, 4, null, null]);
ds.shift(-2);