Skip to content

Commit

Permalink
refactor(api): remove IntegerValue.label
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `IntegerValue.label` is redundant with the `IntegerValue.cases` method, use that instead.
  • Loading branch information
cpcloud committed Dec 18, 2024
1 parent 911d9d4 commit 91d01c3
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions ibis/expr/types/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from ibis.util import deprecated

if TYPE_CHECKING:
from collections.abc import Iterable

import ibis.expr.types as ir


Expand Down Expand Up @@ -1594,41 +1592,6 @@ def __invert__(self) -> IntegerValue:
else:
return node.to_expr()

def label(self, labels: Iterable[str], nulls: str | None = None) -> ir.StringValue:
"""Label a set of integer values with strings.
Parameters
----------
labels
An iterable of string labels. Each integer value in `self` will be mapped to
a value in `labels`.
nulls
String label to use for `NULL` values
Returns
-------
StringValue
`self` labeled with `labels`
Examples
--------
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"a": [0, 1, 0, 2]})
>>> t.select(t.a, labeled=t.a.label(["a", "b", "c"]))
┏━━━━━━━┳━━━━━━━━━┓
┃ a ┃ labeled ┃
┡━━━━━━━╇━━━━━━━━━┩
│ int64 │ string │
├───────┼─────────┤
│ 0 │ a │
│ 1 │ b │
│ 0 │ a │
│ 2 │ c │
└───────┴─────────┘
"""
return self.cases(*enumerate(labels), else_=nulls)


@public
class IntegerScalar(NumericScalar, IntegerValue):
Expand Down

0 comments on commit 91d01c3

Please sign in to comment.