-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list_concat([list<T>, list<T>])
gives list<T>
, not list<list<T>>
#17294
Comments
It is a concat list operation. It concats the lists. If you want to create an extra level of nesting you need to |
@ritchie46 I think this is a valid issue. Why do the following two produce the same result? pl.DataFrame({"a": [1], "b": [2]}).select(
pl.concat_list("a", "b")
)
# shape: (1, 1)
# ┌───────────┐
# │ a │
# │ --- │
# │ list[i64] │
# ╞═══════════╡
# │ [1, 2] │
# └───────────┘
pl.DataFrame({"a": [[1]], "b": [[2]]}).select( # note the [[1]]
pl.concat_list("a", "b")
)
# shape: (1, 1)
# ┌───────────┐
# │ a │
# │ --- │
# │ list[i64] │
# ╞═══════════╡
# │ [1, 2] │
# └───────────┘ The documentation says "Horizontally concatenate columns into a single list column." If the columns are lists, then they should form a list of lists. Edit: I just noticed there is more to the documentation in 1.0 which isn't on the current 0.2 documentation, that clarifies. |
FYI I feel that |
The initial implosion is because there isn't any list yet. So in order to concat them, they are imploded. I think we should improve the description here. |
@ritchie46 the description's improved in the 1.0 docs, I had missed that. |
@mcrumiller pinpoints my exact confusion. I agree there should be two functions, one that is a constructor as in |
I'm looking for the constructor. What could I use for that currently? |
Hi @NickCrews, can you be a little more specific about what you want to do? |
Yes, but I'll get to it in an hour or two once I can get back to my computer |
Actually, I think we should move all discussion to #8510. Specifically, I responded in this comment in that issue. |
Workaround for pola-rs/polars#17294 pl.concat_list(Iterable[T]) results in pl.List[T], EXCEPT when T is a pl.List, in which case pl.concat_list(Iterable[pl.List[T]]) results in pl.List[T]. If polars ever supports a more consistent array constructor, we should switch to that. Found this when working on #9473
Checks
Reproducible example
Log output
Issue description
see above
Expected behavior
see above
Installed versions
The text was updated successfully, but these errors were encountered: