Skip to content

How to perform positional joins (concatenate columns) with ibis? #8329

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

You must be logged in to vote

This is now possible with a few of the in-memory backends using how="positional" with joins. Here's DuckDB:

In [16]: import datetime as dt

In [17]: from ibis.interactive import *

In [18]: t = ibis.memtable(
    ...:     {
    ...:         "store_id": [1] * 5 + [2] * 5,
    ...:         "date": [dt.datetime(2022, 1, x) for x in [2, 3, 4, 5, 6]]
    ...:         + [dt.datetime(2022, 1, x) for x in [2, 5, 6, 7, 9]],
    ...:         "value": [1, 2, 3, 4, 5] + [1, 4, 5, 6, 8],
    ...:     },
    ...:     name="t",
    ...: )

In [19]: t
Out[19]:
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ store_id ┃ date                ┃ value ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│ int64    │ time…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ogrisel
Comment options

@gforsyth
Comment options

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
3 participants