if i have a column of list of strings, is there a ...
# general
k
if i have a column of list of strings, is there a way I can apply the str expressions on the values in my column of lists?
j
Not at the moment… What do you think is a good API?
Copy code
df = df.with_column(
    "mapped",
    df["list_of_strings"].list.eval(daft.element().str.left())
)
What about this API?
k
I was thinking of df = df.with_column( "mapped", df["list_of_strings"].list.apply(str.left()) ) where the function applied to the element is an available expression and matches the type in the expression as well
j
Yeah the problem is that
str.left()
is not possible since
str
isn’t a type we control… Another possible approach is maybe a lambda:
Copy code
.list.apply(lambda item: item.str.left())
I’m afraid this gets a little confused with our current
.apply
which is a convenience method over UDFs though
k
Ah I see.. i was keeping str from the syntax used in the expressions so i would expect that it can also be used for a list within a list etc.. 😅
j
Yeah
str
in Python is just…. Python
str
so it wouldn’t work 😢
k
That's true
j
Ok we’ll come up with something here. Seems like a pretty common ask
Could you make an issue for us please?
❤️ appreciate it@
k
Expression.str.left?
Yup okay!
j
Nope, for
.list.apply
k
Got it!