Skip to content

How to create a json column, based on other columns? #11051

Discussion options

You must be logged in to vote

Ah, ok, so something like

[ins] In [21]: t
Out[21]: 
┏━━━━━━━┓
┃ a     ┃
┡━━━━━━━┩
│ int64 │
├───────┤
│     1 │
│     2 │
│     3 │
└───────┘

[ins] In [22]: t.mutate(b=ibis.struct({'column_a': t.a}).cast('json'))
Out[22]: 
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ ab                    ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ int64json                 │
├───────┼──────────────────────┤
│     1 │ {'column_a': 1}      │
│     2 │ {'column_a': 2}      │
│     3 │ {'column_a': 3}      │
└───────┴──────────────────────┘

?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@felipeangelimvieira
Comment options

@gforsyth
Comment options

Answer selected by felipeangelimvieira
@felipeangelimvieira
Comment options

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