maxframe.liteframe.LiteFrame.shift#
- LiteFrame.shift(periods=1, fill_value=None, columns=None)#
Shift rows by
periodspositions.Positive
periodsshifts data forward (down); negative shifts backward (up). Positions introduced by the shift are filled withfill_value(default: null).- Parameters:
periods (int, default 1) – Number of positions to shift. Positive = forward, negative = backward.
fill_value (scalar, default None) – Value to fill positions introduced by shifting. None produces null.
columns (str, list of str, or None, default None) – Column(s) to shift. If None, all columns are shifted. Non-selected columns are passed through unchanged.
- Returns:
Shifted LiteFrame with the same shape and columns. Output dtypes depend on the input dtype and
fill_value: whenfill_valueis None (the default) input dtypes are preserved; when afill_valueis supplied a column may be widened (e.g. an integer column with a float fill becomes Float64, a string fill becomes String). Boolean columns coerce numeric fills to bool; decimal columns derive precision from the fill value; a string fill on a boolean column is rejected at plan time. Non-selected (passthrough) columns keep their input dtypes.- Return type:
See also
diffCompute the difference between consecutive rows.
pct_changeCompute percent change over given periods.
rollingProvide rolling-window calculations.
Examples
>>> import maxframe.liteframe as mlf >>> lf = mlf.LiteFrame({'a': [1, 2, 3, 4]}) >>> result = lf.shift(1) >>> result.execute() a 0 NaN 1 1.0 2 2.0 3 3.0