polars
polars copied to clipboard
fill_null changes dtype
Checks
- [X] I have checked that this issue has not already been reported.
- [X] I have confirmed this bug exists on the latest version of Polars.
Reproducible example
(
pl.LazyFrame(
pl.Series('a', [1, 2, None], dtype=pl.UInt16)
)
.inspect()
.with_columns(
pl.col('a').fill_null(0)
)
.collect()
)
Log output
shape: (3, 1)
┌──────┐
│ a │
│ --- │
│ u16 │
╞══════╡
│ 1 │
│ 2 │
│ null │
└──────┘
shape: (3, 1)
┌─────┐
│ a │
│ --- │
│ i32 │
╞═════╡
│ 1 │
│ 2 │
│ 0 │
└─────┘
Issue description
fill_null should not change dtype
pl.Series('a', [1, 2, None], dtype=pl.UInt32).fill_null(0).dtype != pl.UInt32
Expected behavior
Don't change dtype
Installed versions
Polars: 0.20.23
Index type: UInt32
Platform: Linux-6.6.22-linuxkit-aarch64-with-glibc2.36
Python: 3.12.3 (main, Apr 24 2024, 07:13:43) [GCC 12.2.0]
----Optional dependencies----
adbc_driver_manager: <not installed>
cloudpickle: <not installed>
connectorx: <not installed>
deltalake: <not installed>
fastexcel: <not installed>
fsspec: <not installed>
gevent: <not installed>
hvplot: <not installed>
matplotlib: <not installed>
nest_asyncio: <not installed>
numpy: <not installed>
openpyxl: <not installed>
pandas: <not installed>
pyarrow: <not installed>
pydantic: <not installed>
pyiceberg: <not installed>
pyxlsb: <not installed>
sqlalchemy: <not installed>
xlsx2csv: <not installed>
xlsxwriter: <not installed>```
</details>
For reference: https://github.com/pola-rs/polars/issues/13789#issuecomment-1937525648
We should actually raise, but we currently do not have the infrastructure to do so yet.
Closing as duplicate of #13789