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

bug(pandas): TypeError: pipe() missing 1 required positional argument: 'f' when calling .seconds() on Interval #2258

Closed
tswast opened this issue Jun 29, 2020 · 2 comments · Fixed by #3416
Labels
bug Incorrect behavior inside of ibis pandas The pandas backend

Comments

@tswast
Copy link
Collaborator

tswast commented Jun 29, 2020

If I to subtract two timestamp columns to get an interval, it works and I'm able to execute on the pandas backend. If I then try to call .seconds() or .milliseconds() on that interval, the pandas backend fails with TypeError: pipe() missing 1 required positional argument: 'f'

Working code:

import ibis
import pandas


source_df = pandas.DataFrame({"timecol": [pandas.Timestamp("2020-06-30T16:00:00Z")]})
target_df = pandas.DataFrame({"timecol": [pandas.Timestamp("2020-07-01T16:00:00Z")]})

client = ibis.pandas.connect(
    {"source": source_df, "target": target_df}
)

source = client.table("source")
target = client.table("target")
joined = source.cross_join(target)
difference = joined[
    (
        target["timecol"] - source["timecol"]
    ).name("difference")
]

print(difference.execute())

Output:

$ python interval.py
  difference
0     1 days

Broken code:

import ibis
import pandas


source_df = pandas.DataFrame({"timecol": [pandas.Timestamp("2020-06-30T16:00:00Z")]})
target_df = pandas.DataFrame({"timecol": [pandas.Timestamp("2020-07-01T16:00:00Z")]})

client = ibis.pandas.connect(
    {"source": source_df, "target": target_df}
)

source = client.table("source")
target = client.table("target")
joined = source.cross_join(target)
difference_seconds = joined[
    (
        target["timecol"] - source["timecol"]
    ).seconds().name("difference")
]

print(difference_seconds.execute())

Output:

$ python interval.py
Traceback (most recent call last):
  File "interval.py", line 17, in <module>
    target["timecol"] - source["timecol"]
TypeError: pipe() missing 1 required positional argument: 'f'
@tswast
Copy link
Collaborator Author

tswast commented Feb 3, 2021

Maybe Ibis should be calling df["difference"].dt.total_seconds() instead of whatever it's currently doing for the seconds()

@cpcloud cpcloud changed the title pandas backend: TypeError: pipe() missing 1 required positional argument: 'f' when calling .seconds() on Interval bug(pandas): TypeError: pipe() missing 1 required positional argument: 'f' when calling .seconds() on Interval Dec 29, 2021
@cpcloud cpcloud added pandas The pandas backend bug Incorrect behavior inside of ibis labels Dec 29, 2021
@gforsyth
Copy link
Member

gforsyth commented Feb 7, 2022

Hey @tswast -- thanks for the convenient test case!

It works if we remove the method call on seconds:

import ibis
import pandas


source_df = pandas.DataFrame({"timecol": [pandas.Timestamp("2020-06-30T16:00:00Z")]})
target_df = pandas.DataFrame({"timecol": [pandas.Timestamp("2020-07-01T16:00:00Z")]})

client = ibis.pandas.connect(
    {"source": source_df, "target": target_df}
)

source = client.table("source")
target = client.table("target")
joined = source.cross_join(target)
difference_seconds = joined[
    (
        target["timecol"] - source["timecol"]
    ).seconds.name("difference")
]

We're going to remove the blanket __call__ on expressions to avoid these errors moving forward

gforsyth added a commit to gforsyth/ibis that referenced this issue Feb 7, 2022
__call__ is gone and it isn't coming back.

Resolves ibis-project#2258

BREAKING CHANGE: `Expr() -> Expr.pipe()`
gforsyth added a commit to gforsyth/ibis that referenced this issue Feb 7, 2022
`__call__` is gone and it isn't coming back.

Resolves ibis-project#2258

BREAKING CHANGE: `Expr() -> Expr.pipe()`
cpcloud pushed a commit that referenced this issue Feb 7, 2022
`__call__` is gone and it isn't coming back.

Resolves #2258

BREAKING CHANGE: `Expr() -> Expr.pipe()`
saulpw pushed a commit to saulpw/ibis that referenced this issue Feb 8, 2022
`__call__` is gone and it isn't coming back.

Resolves ibis-project#2258

BREAKING CHANGE: `Expr() -> Expr.pipe()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis pandas The pandas backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants