Skip to content
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

Introduce window-function #227

Closed
2 tasks
dmpetrov opened this issue Aug 2, 2024 · 1 comment · Fixed by #515
Closed
2 tasks

Introduce window-function #227

dmpetrov opened this issue Aug 2, 2024 · 1 comment · Fixed by #515
Assignees
Labels
enhancement New feature or request priority-p2

Comments

@dmpetrov
Copy link
Member

dmpetrov commented Aug 2, 2024

I have a dataset with column Class which takes one of categorical values like Dog, Cat etc...

  • I need to select a subset of the records with 5 records in each class.
  • I need the same but the subset has to be randomized.

This is how it looks like in IBIS (with randomization):

# Create a random column for ordering
random_col = table.mutate(random_val=ibis.random())

# Define a window function partitioned by 'Class' and ordered by the random column
window = win.Window(partition_by='Class', order_by=random_col.random_val)

# Add a row number column based on the window function
ranked_table = random_col.mutate(row_number=ibis.row_number().over(window))
@dmpetrov dmpetrov added enhancement New feature or request priority-p2 labels Aug 2, 2024
@dreadatour dreadatour self-assigned this Oct 15, 2024
@dreadatour dreadatour linked a pull request Oct 16, 2024 that will close this issue
@dreadatour
Copy link
Contributor

Merged. Will continue in the follow-up issues #522 and #523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants