pola-rs/polars

`pl.datetime` needs a way to fail silently

Open

#21 898 ouverte le 23 mars 2025

Voir sur GitHub
 (9 commentaires) (1 réaction) (0 assignés)Rust (2 826 forks)batch import
buggood first issueneeds triagepython

Métriques du dépôt

Stars
 (38 496 stars)
Métriques de merge PR
 (Merge moyen 3j 18h) (175 PRs mergées en 30 j)

Description

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({
    'year': [2024],
    'month': [1],
    'day': [1],
    'hour': [1],
    'minute': [1],
    'second': [63],
})

res = df.select(
    pl.datetime('year', 'month', 'day', 'hour', 'minute', 'second')
)

Log output

Issue description

pl.datetime used to silently fail and output a null.

Due to https://github.com/pola-rs/polars/pull/21013 it now throws a ComputeError: Invalid time components.

I've got no issue with the new behavior, but can we add a flag back to fail with a null? Run into this with some data processing.

Thanks

Expected behavior

Given a flag it would output a null on ComputeError

Installed versions

--------Version info---------
Polars:              1.23.0
Index type:          UInt32
Platform:            Linux-6.12.7-arch1-1-x86_64-with-glibc2.41
Python:              3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:36:51) [GCC 12.4.0]
LTS CPU:             False

----Optional dependencies----
Azure CLI            <not installed>
adbc_driver_manager  <not installed>
altair               5.4.1
azure.identity       <not installed>
boto3                1.34.59
cloudpickle          3.0.0
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               2024.5.0
gevent               24.2.1
google.auth          2.28.2
great_tables         <not installed>
matplotlib           3.8.4
numpy                1.26.3
openpyxl             3.1.2
pandas               3.0.0.dev0+756.ge8e6be071c
polars_cloud         <not installed>
pyarrow              20.0.0.dev130+geae901e6aa.d20250226
pydantic             2.10.4
pyiceberg            <not installed>
sqlalchemy           2.0.30
torch                2.4.1+cu121
xlsx2csv             <not installed>
xlsxwriter           <not installed>```

</details>

Guide contributeur