Skip to content

Get substring of column value #9889

Answered by gforsyth
vmsaipreeth asked this question in Q&A
Discussion options

You must be logged in to vote

You can use join on an array of strings:

[ins] In [7]: t
Out[7]: 
┏━━━━━━━━━━━━━━━━━━━━━━┓
┃ a                    ┃
┡━━━━━━━━━━━━━━━━━━━━━━┩
│ array<string>        │
├──────────────────────┤
│ ['xy', 'abcd']       │
│ ['abc']              │
└──────────────────────┘

[ins] In [8]: t.mutate(concat_col=t.a.join("-"))
Out[8]: 
┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ aconcat_col ┃
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ array<string>string     │
├──────────────────────┼────────────┤
│ ['xy', 'abcd']       │ xy-abcd    │
│ ['abc']              │ abc        │
└──────────────────────┴────────────┘

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vmsaipreeth
Comment options

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