Comments (5)
Correct on numeric. One way around that might be to encode with a CategoricalArray
and control the sort order with that. (I didn't try that.)
Or, someone could PR the use of a KW arg to add this feature.
from dataframesmeta.jl.
It works for me:
julia> using DataFrames, DataFramesMeta
julia> d = DataFrame(n = 1:20, x = [3, 3, 3, 3, 1, 1, 1, 2, 1, 1,
2, 1, 1, 2, 2, 2, 3, 1, 1, 2]);
julia> @orderby(d, -:x)
20×2 DataFrames.DataFrame
│ Row │ n │ x │
├─────┼────┼───┤
│ 1 │ 1 │ 3 │
│ 2 │ 2 │ 3 │
│ 3 │ 3 │ 3 │
│ 4 │ 4 │ 3 │
│ 5 │ 17 │ 3 │
│ 6 │ 8 │ 2 │
│ 7 │ 11 │ 2 │
│ 8 │ 14 │ 2 │
│ 9 │ 15 │ 2 │
│ 10 │ 16 │ 2 │
│ 11 │ 20 │ 2 │
│ 12 │ 5 │ 1 │
│ 13 │ 6 │ 1 │
│ 14 │ 7 │ 1 │
│ 15 │ 9 │ 1 │
│ 16 │ 10 │ 1 │
│ 17 │ 12 │ 1 │
│ 18 │ 13 │ 1 │
│ 19 │ 18 │ 1 │
│ 20 │ 19 │ 1 │
julia> g = groupby(d, :x);
julia> @orderby(g, -mean(:n))
DataFrames.GroupedDataFrame 3 groups with keys: Symbol[:x]
First Group:
6×2 DataFrames.SubDataFrame{Array{Int64,1}}
│ Row │ n │ x │
├─────┼────┼───┤
│ 1 │ 8 │ 2 │
│ 2 │ 11 │ 2 │
│ 3 │ 14 │ 2 │
│ 4 │ 15 │ 2 │
│ 5 │ 16 │ 2 │
│ 6 │ 20 │ 2 │
⋮
Last Group:
5×2 DataFrames.SubDataFrame{Array{Int64,1}}
│ Row │ n │ x │
├─────┼────┼───┤
│ 1 │ 1 │ 3 │
│ 2 │ 2 │ 3 │
│ 3 │ 3 │ 3 │
│ 4 │ 4 │ 3 │
│ 5 │ 17 │ 3 │
from dataframesmeta.jl.
Unfortunately that doesn't seem to be supported currently. However it shouldn't be hard to support, by adding a keyword argument and passing it to sortperm
.
from dataframesmeta.jl.
I guess that only works for numeric columns...
from dataframesmeta.jl.
Closed in favor of #166
from dataframesmeta.jl.
Related Issues (20)
- 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
- 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
- Request @rsubset_rtransform 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
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.