Skip to content

how to concat strings in a group_by operation #5783

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

You must be logged in to vote

Hi @Arengard 👋🏻!

Love the enthusiasm!!!

You can use the .collect() method of Arrays to do the non-unique version:

In [7]: from ibis.interactive import *

In [8]: t = ex.diamonds.fetch()

In [9]: t.group_by("color").agg(cuts=_.cut.collect())
Out[9]:
┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ color  ┃ cuts                                  ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ string │ array<string>                         │
├────────┼───────────────────────────────────────┤
│ E      │ ['Ideal', 'Premium', ... +9795]       │
│ I      │ ['Premium', 'Very Good', ... +5420]   │
│ J      │ ['Good', 'Very Good', ... +2806]      │
│ H      │ ['Very Good', 'Very Good', ..…

Replies: 1 comment

Comment options

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