Giter VIP home page Giter VIP logo

Comments (7)

pdeffebach avatar pdeffebach commented on June 26, 2024 1

What about

combine(gd) do sdf
    @with sdf begin
        :x1
     end
end

You have to repeat sdf twice, but you can get both the sdf and use the columns nicely.

from dataframesmeta.jl.

pdeffebach avatar pdeffebach commented on June 26, 2024

I don't think it would be possible to have something like the following

@by df :col1 begin
    :x1 # Column in df
    _subdf # reserved name for subdf
end

Since this is not possible in the src => fun => dest mini-language.

I think what you want is essentially

by(fun, df, groupcol) = combine(fun, groupby(df, groupcol))

I'm not sure this is worth it, but if so, it would belong in DataFrames.jl, not DataFramesMeta.jl, which is reserved for metaprogramming.

from dataframesmeta.jl.

HenriDeh avatar HenriDeh commented on June 26, 2024

What about an inner macro then?

@by df :col1 begin
    @withsubdf nrow(:x1)
end

to tell the outer macro that we want the :x1 column of the subdf and not that of the main df.

from dataframesmeta.jl.

pdeffebach avatar pdeffebach commented on June 26, 2024

That's currently pretty close to what's implemented, right?

@by df :col1 begin
    :y = f(:col2)
end

from dataframesmeta.jl.

HenriDeh avatar HenriDeh commented on June 26, 2024

This will apply f to the entire column of df, but not to the subdataframes created by groupby.
It is not equivalent to

combine(groupby(df, :col1)) do sdf
    f(sdf.col2)
end

which does apply f to the subdataframes.

from dataframesmeta.jl.

HenriDeh avatar HenriDeh commented on June 26, 2024

Nevermind, one can actually use length(:col2) to get the size of the df. We still cannot work with the subdf, unlike the DataFrame do syntax, but the applications are not that numerous.

from dataframesmeta.jl.

HenriDeh avatar HenriDeh commented on June 26, 2024

Yes that's fairly clean. No need for a dedicated macro with this syntax in my opinion. Thank you.

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.