Comments (7)
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.
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.
@when
is a good name I think.
from dataframesmeta.jl.
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.
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.
@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.
That's awesome Peter. Shortens the code a lot.
from dataframesmeta.jl.
Related Issues (20)
- typos HOT 3
- Macro @rolling for scrolling through a column or columns of values? HOT 3
- Add a `@bycol` macro-flag HOT 5
- Add metadata for working with DataFrames HOT 1
- Access subdf in @by and @combine HOT 7
- Request - grouped by columns available as single values rather than vectors HOT 5
- Request: `@order` to mimic `DataFrames.order` in `@orderby` HOT 2
- Very slow `@astable` macro outside a function HOT 4
- `@with` macro clashes with `Base.@with` in Julia 1.11+ HOT 8
- `ByRow` not defined when importing DataFramesMeta HOT 1
- docs question HOT 7
- Special-case `==` as with other one-argument functions HOT 2
- Add an alternative syntax escaping than `$` HOT 1
- MethodError occurred when broadcasting a string inside @astable HOT 3
- Speculative future of `@groupby` macro
- Allow reference to previously defined columns in @transform HOT 7
- `groupby` derived columns
- Add convenience function to look up a single value in a `DataFrame` HOT 2
- Error in the @by example in the documentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dataframesmeta.jl.