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

Dot product of two integer series is cast to float #12129

Closed
2 tasks done
Wainberg opened this issue Oct 31, 2023 · 1 comment · Fixed by #15506
Closed
2 tasks done

Dot product of two integer series is cast to float #12129

Wainberg opened this issue Oct 31, 2023 · 1 comment · Fixed by #15506
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@Wainberg
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

>>> pl.Series([1,2,3]) @ pl.Series([4,5,6])
32.0
>>> pl.Series([1,2,3]).dot(pl.Series([4,5,6]))
32.0

Log output

No response

Issue description

The dot product of two integer series is a float when using either @ or dot.

Expected behavior

The dot product should be an integer.

Installed versions

--------Version info---------
Polars:              0.19.12
Index type:          UInt32
Platform:            Linux-4.4.0-22621-Microsoft-x86_64-with-glibc2.35
Python:              3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:40:35) [GCC 12.3.0]

----Optional dependencies----
adbc_driver_sqlite:  0.7.0
cloudpickle:         3.0.0
connectorx:          0.3.2
deltalake:           0.10.1
fsspec:              2023.10.0
gevent:              23.9.1
matplotlib:          3.8.0
numpy:               1.26.1
openpyxl:            3.1.2
pandas:              2.1.2
pyarrow:             13.0.0
pydantic:            2.4.2
pyiceberg:           0.5.0
pyxlsb:              1.0.10
sqlalchemy:          2.0.22
xlsx2csv:            0.8.1
xlsxwriter:          3.1.9
@Wainberg Wainberg added bug Something isn't working python Related to Python Polars labels Oct 31, 2023
@Wainberg
Copy link
Contributor Author

The same thing happens with pow, with the additional problem that string and boolean columns are also automatically cast to float:

>>> pl.DataFrame({'a': [1, 2, 3], 'b': ['4', '5', '6'], 'c': [True, False, True]}).with_columns(pl.all() ** 2)
 a    b     c
 1.0  16.0  1.0
 4.0  25.0  0.0
 9.0  36.0  1.0
shape: (3, 3)
>>> pl.DataFrame({'a': [1, 2, 3], 'b': ['4', '5', '6'], 'c': [True, False, True]}).with_columns(pl.all().pow(2))
 a    b     c
 1.0  16.0  1.0
 4.0  25.0  0.0
 9.0  36.0  1.0
shape: (3, 3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants