Skip to content

bug: ibis.pivot_wider fails when names_from is not string #11615

@vspinu

Description

@vspinu

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior inside of ibis

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions