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
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
The type of the error raised when adding a number to a non-numeric series depends on the dtype of the series:
>>> from datetime import date >>> import polars as pl >>> pl.Series("x", [date.today()]) + 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/a/Work/abalkin/polars/py-polars/polars/internals/series/series.py", line 534, in __add__ return self._arithmetic(other, "add", "add_<>") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/a/Work/abalkin/polars/py-polars/polars/internals/series/series.py", line 512, in _arithmetic other = maybe_cast(other, self.dtype, self.time_unit) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/a/Work/abalkin/polars/py-polars/polars/datatypes.py", line 802, in maybe_cast el = py_type(el) # type: ignore[call-arg] ^^^^^^^^^^^ TypeError: function missing required argument 'month' (pos 2) >>> pl.Series("x", [""]) + 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/a/Work/abalkin/polars/py-polars/polars/internals/series/series.py", line 534, in __add__ return self._arithmetic(other, "add", "add_<>") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/a/Work/abalkin/polars/py-polars/polars/internals/series/series.py", line 515, in _arithmetic raise ValueError( ValueError: cannot do arithmetic with series of dtype: Utf8 and argument of type: <class 'str'>
Expect the same error type in both cases. Probably ValueError error is correct because from Python perspective, dtype is part of the value, not type.
ValueError
>>> pl.show_versions() ---Version info--- Polars: 0.16.1 Index type: UInt32 Platform: macOS-12.6.3-x86_64-i386-64bit Python: 3.11.1 (main, Dec 23 2022, 09:40:27) [Clang 14.0.0 (clang-1400.0.29.202)] ---Optional dependencies--- pyarrow: 11.0.0 pandas: 1.5.3 numpy: 1.24.1 fsspec: <not installed> connectorx: <not installed> xlsx2csv: 0.8.1 deltalake: <version not detected> matplotlib: <not installed>
The text was updated successfully, but these errors were encountered:
Changed this to ValueError in #6677. The message will not be exactly the same as the other example you give, given that this is a different code path.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Polars version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
The type of the error raised when adding a number to a non-numeric series depends on the dtype of the series:
Reproducible example
Expected behavior
Expect the same error type in both cases. Probably
ValueError
error is correct because from Python perspective, dtype is part of the value, not type.Installed versions
The text was updated successfully, but these errors were encountered: