Skip to content

How to explode and select structs in cells #1964

Answered by samster25
CrashLaker asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @CrashLaker,

Thanks for trying out daft! So the issue here is that we currently don't support selector expressions with regex col("Records.*") but we will be adding that soon!

In the mean time, we do provide a struct accessor.

Another idea of what we can do is add a flatten() operation for struct columns (like a horizontal explode) that will give you the output you're looking for.

Workaround example!

In [75]: df = df.explode("Records")

In [76]: df
Out[76]: 
╭────────────────────────────────────────────╮
│ Records                                    │
│ ---                                        │
│ Struct[a: Utf8, b: Utf8, c: Utf8, d: Utf8] │
╰──────────────────────────────────────────…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by CrashLaker
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