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

not yet implemented when call pl.sum_horizontal #13113

Closed
2 tasks done
wukan1986 opened this issue Dec 19, 2023 · 1 comment · Fixed by #13880
Closed
2 tasks done

not yet implemented when call pl.sum_horizontal #13113

wukan1986 opened this issue Dec 19, 2023 · 1 comment · Fixed by #13880
Labels
bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@wukan1986
Copy link

wukan1986 commented Dec 19, 2023

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

import polars as pl

df = pl.DataFrame(
    {
        "A": [5, None, 3, 2, 1],
        "B": [5, 3, None, 2, 1],
        "C": [None, None, None, None, None],
    }
)
print(df.schema)

result = df.select(pl.sum_horizontal(pl.col('A'), pl.col('B'), pl.col('C')))
print(result)

Log output

thread '<unnamed>' panicked at crates\polars-core\src\chunked_array\ops\fill_null.rs:91:18:
not yet implemented
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "b.py", line 12, in <module>
    result = df.select(pl.sum_horizontal(pl.col('A'), pl.col('B'), pl.col('C')))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Kan\miniconda3\envs\py311_1\Lib\site-packages\polars\dataframe\frame.py", line 8009, in select
    return self.lazy().select(*exprs, **named_exprs).collect(_eager=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Kan\miniconda3\envs\py311_1\Lib\site-packages\polars\lazyframe\frame.py", line 1706, in collect
    return wrap_df(ldf.collect())
                   ^^^^^^^^^^^^^
pyo3_runtime.PanicException: not yet implemented

Issue description

if a column dtype is pl.Null it will throw exception

Expected behavior

  1. treat null as 0 when sum_horizontal
  2. treat null as 1 when prod_horizontal

Installed versions

--------Version info---------
Polars:               0.20.1
Index type:           UInt32
Platform:             Windows-10-10.0.22631-SP0
Python:               3.11.3 | packaged by Anaconda, Inc. | (main, Apr 19 2023, 23:46:34) [MSC v.1916 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
matplotlib:           3.7.1
numpy:                1.24.3
openpyxl:             3.1.2
pandas:               2.0.1
pyarrow:              12.0.0
pydantic:             1.10.7
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           2.0.13
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>

@wukan1986 wukan1986 added bug Something isn't working python Related to Python Polars labels Dec 19, 2023
@stinodego stinodego added the accepted Ready for implementation label Dec 20, 2023
@stinodego
Copy link
Member

Thanks, I can confirm this bug. Indeed, Null columns should be treated as the identity for these functions.

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-low Priority: low python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants