Skip to content

How to insert an array / list as a new column in Ibis? #9521

Answered by cpcloud
vadimnazarov asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @vadimnazarov 👋🏻

This may seem simple, but the implicit assumption in this "just working" is that the i-th element of the new_col list corresponds to the i-th row of the table you're attaching it to.

This assumption doesn't hold in general in relational algebra: you have to explicitly tell the query engine how to associate rows, using some kind of join.

We actually just added support for how="positional" joins to support "concat"-style joins for some of the local backends, which may be what you want:

In [3]: from ibis.interactive import *

In [4]: import pandas as pd
   ...: data = ibis.memtable(pd.DataFrame({"a":[1,2,3], "b":[4,5,6]}))
   ...: data.mutate(new_col = [7,8,9])
Out[4]:
┏━…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cpcloud
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