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

Cannot create literal for pd.Timedelta with allow_object=False #18906

Closed
2 tasks done
yiteng-guo opened this issue Sep 24, 2024 · 2 comments · Fixed by #18998
Closed
2 tasks done

Cannot create literal for pd.Timedelta with allow_object=False #18906

yiteng-guo opened this issue Sep 24, 2024 · 2 comments · Fixed by #18998
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@yiteng-guo
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

import polars as pl
import pandas as pd

pl.select(a=pl.lit(pd.Timedelta(minutes=1)))

TypeError: cannot create expression literal for value of type Timedelta: Timedelta('0 days 00:01:00')

Hint: Pass `allow_object=True` to accept any value and create a literal of type Object.

Log output

No response

Issue description

I believe this is the same as #18447 and something like #18497 should fix it.

Expected behavior

It should allow pd.Timedelta since it's a subclass of datetime.timedelta.

Installed versions

Can't do this since it's on the work laptop.

@yiteng-guo yiteng-guo added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Sep 24, 2024
@henryharbeck
Copy link
Contributor

Like #18447, this is a regression from 1.5.
FYI @ritchie46 @MarcoGorelli @mcrumiller

@mcrumiller
Copy link
Contributor

mcrumiller commented Sep 28, 2024

In this case it's cause a pd.Timedelta object has a _s attribute and so our convert thinks it's a list/series.

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

Successfully merging a pull request may close this issue.

3 participants