Coder Social home page Coder Social logo

Comments (5)

tshort avatar tshort commented on May 18, 2024 3

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.

tshort avatar tshort commented on May 18, 2024 2

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 │
├─────┼────┼───┤
│ 113 │
│ 223 │
│ 333 │
│ 443 │
│ 5173 │
│ 682 │
│ 7112 │
│ 8142 │
│ 9152 │
│ 10162 │
│ 11202 │
│ 1251 │
│ 1361 │
│ 1471 │
│ 1591 │
│ 16101 │
│ 17121 │
│ 18131 │
│ 19181 │
│ 20191 │

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 │
├─────┼────┼───┤
│ 182 │
│ 2112 │
│ 3142 │
│ 4152 │
│ 5162 │
│ 6202
Last Group:
5×2 DataFrames.SubDataFrame{Array{Int64,1}}
│ Row │ n  │ x │
├─────┼────┼───┤
│ 113 │
│ 223 │
│ 333 │
│ 443 │
│ 5173

from dataframesmeta.jl.

nalimilan avatar nalimilan commented on May 18, 2024

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.

nalimilan avatar nalimilan commented on May 18, 2024

I guess that only works for numeric columns...

from dataframesmeta.jl.

pdeffebach avatar pdeffebach commented on May 18, 2024

Closed in favor of #166

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.