Giter VIP home page Giter VIP logo

Comments (1)

kieferk avatar kieferk commented on September 2, 2024

Hello - sorry it's been a long time since I checked these issues!

The reason this doesn't work is that pd.to_datetime will try to evaluate X.timestamp immediately, causing an error due to the fact that it doesn't know what to do with X.timestamp.

The error will be different now in v0.3.0, but the reason is the same. If you want to use a custom window function like that in the piping syntax, you need to make a version of it that can "delay itself" when it encounters symbolic arguments.

Luckily this is quite easy, you just need to decorate a function with the @make_symbolic decorator like so:

@make_symbolic
def to_datetime(series):
    return pd.to_datetime(series)

This version of the function can be used inside the pipe:

hub2 >> mutate(time=to_datetime(X.timestamp))

I actually used this a one of the examples in the new readme documentation, because it's perfect for explaining the use of @make_symbolic for custom window functions. Thanks for that!

Hope this helps and clears up the issue for you. Cheers

from dfply.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.