Skip to content

Commit 098e11e

Browse files
authored
add column.shift (#317)
* add column.shift * extra docs * formatting, remove fill_value
1 parent 2e9687b commit 098e11e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

spec/API_specification/dataframe_api/column_object.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,23 @@ def rename(self, name: str) -> Self:
811811
"""
812812
...
813813

814+
def shift(self, offset: int) -> Self:
815+
"""Shift values by `offset` positions, filling missing values with `null`.
816+
817+
For example, if the original column contains values `[1, 4, 2]`, then:
818+
819+
- `.shift(1)` will return `[null, 1, 4]`,
820+
- `.shift(-1)` will return `[4, 2, null]`,
821+
822+
Parameters
823+
----------
824+
offset
825+
How many positions to shift by.
826+
"""
827+
...
828+
829+
# --- temporal methods ---
830+
814831
def year(self) -> Self:
815832
"""Return 'year' component of each element of `Date` and `Datetime` columns.
816833

0 commit comments

Comments
 (0)