polars/polars-categorical-vs-enum
| Rule | polars-categorical-vs-enum |
|---|---|
| Pack | Polars |
| Severity | info |
| Fix | none, edit by hand |
| Library versions | every version |
Categorical accepts every string label. Use Enum when you have a fixed list and want unknown labels to raise.
pl.Series(["open", "closed"], dtype=pl.Categorical)pl.Series(["open", "closed"], dtype=pl.Enum(["open", "closed"]))What the rule reports
Section titled “What the rule reports”Categorical accepted typo. Enum raised InvalidOperationError for 1 unknown value.
How to fix it
Section titled “How to fix it”Edit the code using the replacement in the example.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
Categorical accepts every string label. Use Enum when you have a fixed list and want unknown labels to raise.Browse the other rules of the Polars pack.