Skip to content
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

Multiply all element of an array by value of another column #9948

Closed
tim-x-y-z opened this issue Jul 18, 2023 · 3 comments
Closed

Multiply all element of an array by value of another column #9948

tim-x-y-z opened this issue Jul 18, 2023 · 3 comments
Labels
enhancement New feature or an improvement of an existing feature

Comments

@tim-x-y-z
Copy link
Contributor

tim-x-y-z commented Jul 18, 2023

Problem description

It would fantastic if i could just do:

>>> df=pl.DataFrame({"a": [[1,2,3], [3,4,5]], "b": [0.5, 0.1]})
>>> df.with_columns(
...     new_col=pl.col("a").list.eval(pl.element() * pl.col("b") * 2)
... )

but this currently yields:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tim/Documents/Github/ercot-wind-optimisation/.venv/lib/python3.11/site-packages/polars/dataframe/frame.py", line 7335, in with_columns
    .collect(no_optimization=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tim/Documents/Github/ercot-wind-optimisation/.venv/lib/python3.11/site-packages/polars/lazyframe/frame.py", line 1531, in collect
    return wrap_df(ldf.collect())
                   ^^^^^^^^^^^^^
exceptions.ComputeError: named columns are not allowed in `list.eval`; consider using `element` or `col("")`

on version 0.18.7

On a side note, the error is counter intuitive as here i am using pl.col("").

@tim-x-y-z tim-x-y-z added the enhancement New feature or an improvement of an existing feature label Jul 18, 2023
@ritchie46
Copy link
Member

Duplicate of #9188 and #8006

@stinodego stinodego closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2023
@ritchie46
Copy link
Member

For the record, it is planned, but let's keep discussion in the existing issues.

@stinodego
Copy link
Member

Yeah, the GitHub UI is confusing here. It says "closed as not planned" but the description is "Won't fix, can't repro, duplicate, stale". In this case it's a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants