Comments (5)
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.
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.
from dataframesmeta.jl.
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.
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)
- More examples in docstrings HOT 15
- subset not defined HOT 12
- suggestion - @chainWithRTransform
- Error `.*` not defined with `@by` HOT 12
- The latest version is not installed HOT 3
- `Symbol` Causes Trouble in `@transform!` HOT 1
- Subset with regex HOT 2
- Bug in the example of DataFramesMeta doc. HOT 2
- Problem with eachrow and eachrow! + break/continue
- Problems in @orderby HOT 2
- Keyword Argument Not Working for `@rsubset` HOT 6
- Work with symbols and integers on the RHS HOT 1
- Special case request for Not() HOT 3
- Github releases not in sync with registered versions HOT 8
- operators do not work inside function call inside macros HOT 3
- 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
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.