You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
anergictcell opened this issue
Jul 30, 2024
· 2 comments
· Fixed by #20422
Assignees
Labels
A-panicArea: code that results in panic exceptionsacceptedReady for implementationbugSomething isn't workingP-lowPriority: lowpythonRelated to Python Polars
map_elements sometimes does not convert None to null if the function returns a custom Python object.
A Python function that returns either a custom Python object or None is not handled correctly by map_elements. It does not convert the returning None to polars null, but instead stores None as an object.
This does only happen when the return_dtype=pl.Object argument is present. When polars guesses the return type, it does handle the None -> null conversion correctly.
Expected behavior
The None values should be stored in the dataframe as null
Installed versions
-------Version info---------
Polars: 1.3.0
Index type: UInt32
Platform: macOS-14.5-arm64-arm-64bit
Python: 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)]
What happens if you set skip_nulls=False within map_elements()? I have been encountering similar issues and setting this param seems to be working? Still trying to make sense of it all though.
A-panicArea: code that results in panic exceptionsacceptedReady for implementationbugSomething isn't workingP-lowPriority: lowpythonRelated to Python Polars
Checks
Reproducible example
Log output
Issue description
map_elements
sometimes does not convertNone
tonull
if the function returns a custom Python object.A Python function that returns either a custom Python object or
None
is not handled correctly bymap_elements
. It does not convert the returningNone
to polarsnull
, but instead storesNone
as an object.This does only happen when the
return_dtype=pl.Object
argument is present. When polars guesses the return type, it does handle theNone -> null
conversion correctly.Expected behavior
The
None
values should be stored in the dataframe asnull
Installed versions
-------Version info---------
Polars: 1.3.0
Index type: UInt32
Platform: macOS-14.5-arm64-arm-64bit
Python: 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)]
----Optional dependencies----
adbc_driver_manager:
cloudpickle:
connectorx:
deltalake:
fastexcel:
fsspec:
gevent:
great_tables:
hvplot:
matplotlib: 3.9.1
nest_asyncio: 1.6.0
numpy: 2.0.1
openpyxl:
pandas:
pyarrow:
pydantic:
pyiceberg:
sqlalchemy:
torch:
xlsx2csv:
xlsxwriter:
The text was updated successfully, but these errors were encountered: