How to insert an array / list as a new column in Ibis? #9521
-
Hello everyone, First of all, I greatly appreciate the work you have done with Ibis. Thank you! I have been using Ibis and really enjoying it, but I recently stumbled upon a relatively simple yet unsolvable use case. I need to add a new column to an existing Ibis table with values from a NumPy array (or a list). However, I can't find a straightforward way to achieve this. Code: import ibis
import pandas as pd
ibis.options.interactive = True
data = ibis.memtable(pd.DataFrame({"a":[1,2,3], "b":[4,5,6]}))
data.mutate(new_col = [7,8,9])
I want to add
How to do that? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @vadimnazarov 👋🏻 This may seem simple, but the implicit assumption in this "just working" is that the i-th element of the 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
|
Beta Was this translation helpful? Give feedback.
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: