Skip to content

str.to_time() does not work if all values are null #22774

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

Open
2 tasks done
lonestike opened this issue May 16, 2025 · 0 comments
Open
2 tasks done

str.to_time() does not work if all values are null #22774

lonestike opened this issue May 16, 2025 · 0 comments
Labels
A-temporal Area: date/time functionality bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@lonestike
Copy link

lonestike commented May 16, 2025

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

df = pl.DataFrame(
    {"timestamp": [None, None], "other": ["text1", "text2"]}, 
    schema_overrides={"timestamp": pl.String},
)

# does not work:
df.with_columns(pl.col("timestamp").str.to_time())

# does work
df.with_columns(pl.col("timestamp").str.to_time("%H"))

Issue description

Hello,
When all the values are null in a string column, polars can't parse them to time unless we specify a format (whatever the format is, it works)

maybe linked to #22370 ?

Expected behavior

expect df.with_columns(pl.col("timestamp").str.to_time()) to work when all the values are null in a str column

Installed versions

\--------Version info---------
Polars:              1.29.0
Index type:          UInt32
Platform:            Linux-3.10.0-1160.108.1.el7.x86\_64-x86\_64-with-glibc2.17
Python:              3.10.4 (main, Mar 31 2022, 08:41:55) \[GCC 7.5.0]
LTS CPU:             False

\----Optional dependencies----
Azure CLI            <not installed>
adbc\_driver\_manager  1.6.0
altair               <not installed>
azure.identity       1.21.0
boto3                1.35.42
cloudpickle          3.0.0
connectorx           <not installed>
deltalake            0.25.5
fastexcel            <not installed>
fsspec               2025.3.2
gevent               <not installed>
google.auth          2.38.0
great\_tables         <not installed>
matplotlib           3.9.2
numpy                2.0.0
openpyxl             3.1.5
pandas               2.2.3
polars\_cloud         <not installed>
pyarrow              17.0.0
pydantic             2.11.4
pyiceberg            0.9.0
sqlalchemy           2.0.35
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           3.2.0
@lonestike lonestike added bug Something isn't working python Related to Python Polars needs triage Awaiting prioritization by a maintainer labels May 16, 2025
@MarcoGorelli MarcoGorelli added A-temporal Area: date/time functionality P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-temporal Area: date/time functionality bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

2 participants