Skip to content

Adding a new column as Nth column #9390

Discussion options

You must be logged in to vote

hi @vmsaipreeth! you're probably looking for table.relocate() -- you can specify a list of column names or dynamically grab them from the table. apologies, I don't think there's a way of directly do this within a single mutate but relocate could help

docs here: https://ibis-project.org/reference/expression-tables.html#ibis.expr.types.relations.Table.relocate

quick example

[ins] In [1]: import ibis
ibi
[ins] In [2]: ibis.options.interactive = True

[ins] In [3]: t = ibis.examples.penguins.fetch()
t.muta
[ins] In [4]: t.mutate(new_col=ibis.literal("something"))
Out[4]:
┏━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┓
┃ s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vmsaipreeth
Comment options

Answer selected by vmsaipreeth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants