ibis icon indicating copy to clipboard operation
ibis copied to clipboard

bug: ibis.pivot_wider fails when names_from is not string

Open vspinu opened this issue 3 months ago • 0 comments

What happened?

Would it be possible either fail with clear error if names_from is not string, or cast to string internally? Thanks!

df = pl.DataFrame([{'series': 0,
  'day': 0,
  'pos': 7,
  'neg': 17},
 {'series': 0,
  'day': 3,
  'pos': 34,
  'neg': 17}])

tbl = ibis.memtable(df)
wtbl = tbl.pivot_wider(
    names_from="day",
    id_cols=["series", "pos", "neg"],
    values_from=["pos", "neg"],
    values_fill=0,
    names_sort=True,
    names_sep=":",
)

  File ibis/expr/types/relations.py:4461 in pivot_wider
    id_cols: s.Selector | None = None,

TypeError: sequence item 1: expected str instance, int found

What version of ibis are you using?

10.8

What backend(s) are you using, if any?

polars

Relevant log output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

vspinu avatar Sep 12 '25 10:09 vspinu