GithubHelp home page GithubHelp logo

Comments (7)

bkamins avatar bkamins commented on June 6, 2024 1

Current:

julia> @chain DataFrame(A=1:4, B=[1,1,2,2]) begin
           @rsubset begin
               :B == 1
               @kwarg view=true
           end
           @rtransform! begin
               :A = 10
               :C = 20
           end
           parent
       end
4×3 DataFrame
 Row │ A      B      C
     │ Int64  Int64  Int64?
─────┼───────────────────────
   1 │    10      1       20
   2 │    10      1       20
   3 │     3      2  missing
   4 │     4      2  missing

from dataframesmeta.jl.

pdeffebach avatar pdeffebach commented on June 6, 2024 1

I absolutely want to implement this, ideally with the syntax

@rtransform df @when(:x == 1) :y = :z * 100

or

@rtransform df @when(:x == 1) begin
    :y = :z * 100
    :a = :b * 5
end

In the background we would have something along the lines of

@chain df begin 
    copy
    @rsubset(:x == 1; view = true)
    @rtransform! begin 
      :y = :z * 100
      :a = :b * 5
    end
    parent
end

This is very feasible, I just haven't written it.

from dataframesmeta.jl.

bkamins avatar bkamins commented on June 6, 2024 1

@when is a good name I think.

from dataframesmeta.jl.

Lincoln-Hannah avatar Lincoln-Hannah commented on June 6, 2024

Thanks Bogumil.
I'll probably lay it out as:

@chain DataFrame(A=1:4, B=[1,1,2,2]) begin

    @rsubset(:B == 1; view=true ); @rtransform! begin

        :A = 10
        :C = 20

    end; parent
    
end

I have 5 or so of these subset blocks within a larger @rtransform block. So don't want to have too many lines opening and closing each block.

from dataframesmeta.jl.

lincolnhannah avatar lincolnhannah commented on June 6, 2024

Can you do the same with a group-by?
Have an @rtransform block for each value of :B
That might reduce the amount of code needed to begin. each block

from dataframesmeta.jl.

bkamins avatar bkamins commented on June 6, 2024
@rsubset(:B == 1; view=true )

it does not work AFAICT. You need @kwarg but maybe please double check.

group-by should work, but could you please show the code and output you have in mind to make sure we are on the same page.?

from dataframesmeta.jl.

Lincoln-Hannah avatar Lincoln-Hannah commented on June 6, 2024

That's awesome Peter. Shortens the code a lot.

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.