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

Null cases not handled properly for some list operations #16282

Open
2 tasks done
heshamdar opened this issue May 17, 2024 · 0 comments
Open
2 tasks done

Null cases not handled properly for some list operations #16282

heshamdar opened this issue May 17, 2024 · 0 comments
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@heshamdar
Copy link

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

test = pl.DataFrame({"a": [["hi"], [], None]})
print(test.select(pl.col("a").list.contains("hi")))

test = pl.DataFrame({"a": [["hi"], [], None]})
print(test.select(pl.col("a").list.len()))

Log output

shape: (3, 1)
┌───────┐
│ a     │
│ ---   │
│ bool  │
╞═══════╡
│ true  │
│ false │
│ false │
└───────┘
shape: (3, 1)
┌─────┐
│ a   │
│ --- │
│ u32 │
╞═════╡
│ 1   │
│ 0   │
│ 0   │
└─────┘

Issue description

Some list operations that return a non list type (e.g. contains and len) result in (arguably) incorrect values for null values. In the example above, contains returns False and len returns 0

Expected behavior

operations on null values should just return null

Installed versions

--------Version info---------
Polars:               0.20.26
Index type:           UInt32
Platform:             macOS-14.2.1-arm64-arm-64bit
Python:               3.10.4 (main, May 28 2022, 12:23:44) [Clang 13.1.6 (clang-1316.0.21.2.5)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          3.0.0
connectorx:           <not installed>
deltalake:            0.15.3
fastexcel:            0.9.1
fsspec:               2024.3.1
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.8.3
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             3.1.2
pandas:               2.0.3
pyarrow:              15.0.0
pydantic:             2.7.0
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           2.0.29
torch:                <not installed>
xlsx2csv:             0.8.2
xlsxwriter:           <not installed>
@heshamdar heshamdar added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

1 participant