We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
With numpy and pandas you can expect that setting arr[:] = some_int will broadcast the shape of some_int to fill the shape of the dimension being set.
arr[:] = some_int
some_int
With polars:
import polars as pl a = {"foo":[1,2,3],} df = pl.DataFrame(a) df["foo"] = [1,2,3] df["foo"] = 1 # <-------- Error is here --------------------------------------------------------------------------- ValueError Traceback (most recent call last) File ~/mambaforge/envs/geo2/lib/python3.9/site-packages/polars/internals/frame.py:1458, in DataFrame.__setitem__(self, key, value) 1457 try: -> 1458 self.replace(key, pli.Series(key, value)) 1459 except Exception: File ~/mambaforge/envs/geo2/lib/python3.9/site-packages/polars/internals/series.py:227, in Series.__init__(self, name, values, dtype, strict, nan_to_null) 226 else: --> 227 raise ValueError("Series constructor not called properly.") ValueError: Series constructor not called properly. During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) Input In [24], in <module> 3 df = pl.DataFrame(a) 4 df["foo"] = [1,2,3] ----> 5 df["foo"] = 1 File ~/mambaforge/envs/geo2/lib/python3.9/site-packages/polars/internals/frame.py:1460, in DataFrame.__setitem__(self, key, value) 1458 self.replace(key, pli.Series(key, value)) 1459 except Exception: -> 1460 self.hstack([pli.Series(key, value)], in_place=True) 1461 # df[["C", "D"]] 1462 elif isinstance(key, list): File ~/mambaforge/envs/geo2/lib/python3.9/site-packages/polars/internals/series.py:227, in Series.__init__(self, name, values, dtype, strict, nan_to_null) 225 self._s = pandas_to_pyseries(name, values) 226 else: --> 227 raise ValueError("Series constructor not called properly.") ValueError: Series constructor not called properly.
The text was updated successfully, but these errors were encountered:
No it should not. Thanks for the reminder to deprecate DataFrame.__setitem__. ;)
DataFrame.__setitem__
Try this:
df = pl.DataFrame({ "foo":[1,2,3] }) df.with_column(pl.lit(1).alias("bar"))
Sorry, something went wrong.
Hahaha, very well :D
No branches or pull requests
Describe your feature request
With numpy and pandas you can expect that setting
arr[:] = some_int
will broadcast the shape ofsome_int
to fill the shape of the dimension being set.With polars:
The text was updated successfully, but these errors were encountered: