Git Product home page Git Product logo

Comments (3)

cpcloud avatar cpcloud commented on June 27, 2024 1

Looks like that method already works, so let's document it and close this out!

In [8]: from ibis.interactive import *

In [9]: t = ex.penguins.fetch()

In [10]: expr = t.select("species", "island").value_counts().order_by(s.across(s.contains("count"), _.desc()))

In [11]: ibis.to_sql(expr)
Out[11]:
SELECT
  *
FROM (
  SELECT
    "t1"."species",
    "t1"."island",
    COUNT(*) AS "species_island_count"
  FROM (
    SELECT
      "t0"."species",
      "t0"."island"
    FROM "penguins" AS "t0"
  ) AS "t1"
  GROUP BY
    1,
    2
) AS "t2"
ORDER BY
  "t2"."species_island_count" DESC

In [12]: expr
Out[12]:
┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ species   ┃ island    ┃ species_island_count ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ string    │ string    │ int64                │
├───────────┼───────────┼──────────────────────┤
│ Gentoo    │ Biscoe    │                  124 │
│ Chinstrap │ Dream     │                   68 │
│ Adelie    │ Dream     │                   56 │
│ Adelie    │ Torgersen │                   52 │
│ Adelie    │ Biscoe    │                   44 │
└───────────┴───────────┴──────────────────────┘

from ibis.

cpcloud avatar cpcloud commented on June 27, 2024

@lostmygithubaccount Is there an equivalent dplyr syntax here? Would be good to mirror that as much as possible if it exists.

from ibis.

cpcloud avatar cpcloud commented on June 27, 2024

Looks like in dplyr you can use across:

image

And for desc as well:

image

If that doesn't work we should implement it that way.

Reference: https://dplyr.tidyverse.org/reference/arrange.html

from ibis.

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.