-
-
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
pl.Array
+ pl.lit
PanicException Cannot apply operation on arrays of different lengths
#18831
Comments
Looks like the arrays are expanded into their underlying physical arrays (e.g. f64 here), so it thinks that the literal value is length 2. |
fixed by #18851 |
Thanks @ritchie46 Just testing the new list arithmetic with the same example - it doesn't Panic, but it does raise. Would a similar df = pl.DataFrame({
"A": [[0.1, 0.2], [0.3, 0.4]]
})
df.with_columns(pl.all() * pl.lit([3, 5]))
# InvalidOperationError: can only do arithmetic operations on Series of the same size; got 2 and 1 (df.with_columns(pl.lit([3, 5]))
.select(pl.nth(0) * pl.nth(1))
)
# shape: (2, 1)
# ┌────────────┐
# │ A │
# │ --- │
# │ list[f64] │
# ╞════════════╡
# │ [0.3, 1.0] │
# │ [0.9, 2.0] │
# └────────────┘ |
Yes, the new list arithemetic should indeed broadcast. @itamarst would you be interested in that one, as you worked on that feature? |
My plan once my fix for #8006 is merged is to work on scalars next, yes (but also looks like someone came up with a PR already?) |
Oh, I guess this isn't quite the same as numeric scalars, which is what I was thinking of, but an extension. |
Definitely not an expert on how broadcasting ought to work, but I did add a bunch of comments on additional testing that would be useful based on my experience so far. |
Checks
Reproducible example
Log output
No response
Issue description
Adding as a column first works as expected.
Expected behavior
No panic.
Installed versions
The text was updated successfully, but these errors were encountered: