Git Product home page Git Product logo

Comments (5)

nalimilan avatar nalimilan commented on August 12, 2024

Looks like only the @based_on form (with the @) works:

iris=dataset("datasets", "iris")
@linq iris |> groupby(:Species) |> @based_on(x = mean(:SepalWidth))

But this syntax is probably better, right?

@linq iris |> by(:Species, x=mean(:SepalWidth))

Or maybe I'm missing the difference between by and based_on (@tshort again, do we need both?).

from dataframesmeta.jl.

ElOceanografo avatar ElOceanografo commented on August 12, 2024

If you want to do transformations or calculations in between grouping and summarizing, a sand-alone based_on is nice. For an example, say you've got a data frame with the positions (x) of a bunch of different objects at different times (t), and you want to calculate each object's average speed:

speeds = @linq trajectory |>
    group_by(:object) |>
    transform(timespan = max(:t) - min(:t), displacement = last(:x) - first(:x)) |>
    based_on(avg_speed = :displacement ./ :timespan)

I this could of course all be done on one line, or by defining a helper function, but if you're working in the data-frame-piping style I think a separate based_on or summarise makes things a little clearer...

from dataframesmeta.jl.

ElOceanografo avatar ElOceanografo commented on August 12, 2024

👍

from dataframesmeta.jl.

nalimilan avatar nalimilan commented on August 12, 2024

OK, I see. Though I don't understand the name: what is "based on" what in this operation? Isn't summarise a better term?

from dataframesmeta.jl.

ElOceanografo avatar ElOceanografo commented on August 12, 2024

I believe the ideas is "based on this data frame, calculate these things." I'd tend to agree that summarize is a better term. In dplyr, all the data frame operations are verbs, which is nice for readability.

(Prepare for the coming flame war over whether it should be summarise or summarize ;) )

from dataframesmeta.jl.

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.