Skip to content

add column.shift #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec/API_specification/dataframe_api/column_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,23 @@ def rename(self, name: str) -> Self:
"""
...

def shift(self, offset: int) -> Self:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependent on #308, but offset should ideally be of type Scalar instead of int

"""Shift values by `offset` positions, filling missing values with `null`.

For example, if the original column contains values `[1, 4, 2]`, then:

- `.shift(1)` will return `[null, 1, 4]`,
- `.shift(-1)` will return `[4, 2, null]`,

Parameters
----------
offset
How many positions to shift by.
"""
...

# --- temporal methods ---

def year(self) -> Self:
"""Return 'year' component of each element of `Date` and `Datetime` columns.

Expand Down