Skip to content

Conversation

jjurm
Copy link
Contributor

@jjurm jjurm commented Sep 5, 2025

Motivation

This makes the categories argument accept the same types as in pl.Enum, making it easier to convert from polars dtypes to dataframely dtypes.

Fixes #136.

Changes

dy.Enum.categories is now stored as a pl.Series - happy to think of another solution if you don't think we should convert all sequences to series. However, this is what polars does internally anyway once dy.Enum.dtype is called.

@jjurm jjurm added the enhancement New feature or request label Sep 5, 2025
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f303b3b) to head (3c03c14).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #138   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         2812      2818    +6     
=========================================
+ Hits          2812      2818    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jjurm jjurm changed the title Extend allowed types of the categories arg of dy.Enum feat: Extend allowed types of the categories arg of dy.Enum Sep 5, 2025
@jjurm jjurm marked this pull request as ready for review September 5, 2025 16:43
Copy link
Member

@borchero borchero left a comment

Choose a reason for hiding this comment

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

Neat, looks great, thanks @jjurm! I think it's fine to represent the categories as series, I can't come up with a downside and we mirror the polars API this way. Would love to hear a second opinion on this by @AndreasAlbertQC or @delsner though 😄

Copy link
Collaborator

@AndreasAlbertQC AndreasAlbertQC left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @jjurm! Personally, I'd have gone for list, but I also don't think it's super important 🤷

Copy link
Collaborator

@AndreasAlbertQC AndreasAlbertQC left a comment

Choose a reason for hiding this comment

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

Let's go!

@jjurm jjurm merged commit 22f4b7d into main Sep 8, 2025
23 of 24 checks passed
@jjurm jjurm deleted the issue-136 branch September 8, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Enum classes as categories for pl.Enum
3 participants