{"id":20975910,"url":"https://github.com/banyc/dfsql","last_synced_at":"2025-07-31T06:38:17.619Z","repository":{"id":210566291,"uuid":"726432493","full_name":"Banyc/dfsql","owner":"Banyc","description":"SQL REPL/lib for Data Frames","archived":false,"fork":false,"pushed_at":"2025-05-19T15:25:10.000Z","size":513,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T12:56:34.605Z","etag":null,"topics":["cli","csv","data-analysis","jsonl","ndjson","repl","sql"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/dfsql","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Banyc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-02T11:36:52.000Z","updated_at":"2025-05-19T15:23:50.000Z","dependencies_parsed_at":"2023-12-23T05:19:14.697Z","dependency_job_id":"204530d4-2cd7-43e9-9118-52d6aa9be5dc","html_url":"https://github.com/Banyc/dfsql","commit_stats":null,"previous_names":["banyc/sql-repl","banyc/dfsql"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Banyc/dfsql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Fdfsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Fdfsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Fdfsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Fdfsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Banyc","download_url":"https://codeload.github.com/Banyc/dfsql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Fdfsql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267999812,"owners_count":24178857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","csv","data-analysis","jsonl","ndjson","repl","sql"],"created_at":"2024-11-19T04:48:00.652Z","updated_at":"2025-07-31T06:38:17.596Z","avatar_url":"https://github.com/Banyc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `dfsql`\n\n![](img/terminal.png)\n\n- Revision: the standalone `count` command is replaced with `len`, so make sure to replace `(count)` and `col \"count\"` with `len` and `col \"len\"` respectively.\n  - the unary `count \u003ccol\u003e` command is unaffected.\n\n## Install\n\n```bash\ncargo install dfsql\n```\n\n## How to run\n\n```bash\ndfsql --input your.csv --output a-new.csv\n# ...or\ndfsql -i your.csv -o a-new.csv\n```\n\n## REPL\n\n- `exit`/`quit`: exit the REPL loop.\n  ```bash\n  exit\n  ```\n- `undo`: undo the previous successful operation.\n  ```bash\n  undo\n  ```\n- `reset`: reset all the changes and go back to the original data frame.\n  ```bash\n  reset\n  ```\n- `schema`: show column names and types of the data frame.\n  ```bash\n  schema\n  ```\n- `save`: save the current data frame to a file.\n  ```bash\n  save a-new.csv\n  ```\n\n## Statements\n\n- `select`\n  ```py\n  select \u003cexpr\u003e*\n  ```\n  ```sql\n  select last_name first_name\n  ```\n  - Select columns \"last_name\" and \"first_name\" and collect them into a data frame.\n- Group by\n  ```py\n  group (\u003ccol\u003e | \u003cvar\u003e)* agg \u003cexpr\u003e*\n  ```\n  ```sql\n  group first_name agg (count)\n  ```\n  - Group the data frame by column \"first_name\" and then aggregate each group with the count of the members.\n- `filter`\n  ```py\n  filter \u003cexpr\u003e\n  ```\n  ```sql\n  filter first_name = \"John\"\n  ```\n- `limit`\n  ```py\n  limit \u003cint\u003e\n  ```\n  ```sql\n  limit 5\n  ```\n- `reverse`\n  ```sql\n  reverse\n  ```\n- `sort`\n  ```py\n  sort ((asc | desc | ()) \u003ccol\u003e)*\n  ```\n  ```sql\n  sort icpsr_id\n  ```\n- `use`\n  ```py\n  use \u003cvar\u003e\n  ```\n  ```py\n  use other\n  ```\n  - Switch to the data frame called `other`.\n- join\n  ```py\n  (left | right | inner | full) join \u003cvar\u003e on \u003ccol\u003e \u003ccol\u003e?\n  ```\n  ```py\n  left join other on id ID\n  ```\n  - left join the data frame called `other` on my column `id` and its column `ID`\n\n## Expressions\n\n- `col`: reference to a column.\n  ```py\n  col : (\u003cstr\u003e | \u003cvar\u003e) -\u003e \u003cexpr\u003e\n  ```\n  ```sql\n  select col first_name\n  ```\n- `exclude`: remove columns from the data frame.\n  ```py\n  exclude : \u003cexpr\u003e* -\u003e \u003cexpr\u003e\n  ```\n  ```sql\n  select exclude last_name first_name\n  ```\n- literal: literal values like `42`, `\"John\"`, `1.0`, and `null`.\n- binary operations\n  ```sql\n  select a * b\n  ```\n  - Calculate the product of columns \"a\" and \"b\" and collect the result.\n- unary operations\n  ```sql\n  select -a\n  ```\n  ```sql\n  select sum a\n  ```\n  - Sum all values in column \"a\" and collect the scalar result.\n- `alias`: assign a name to a column.\n  ```py\n  alias : (\u003ccol\u003e | \u003cvar\u003e) \u003cexpr\u003e -\u003e \u003cexpr\u003e\n  ```\n  ```sql\n  select alias product a * b\n  ```\n  - Assign the name \"product\" to the product and collect the new column.\n- conditional\n  ```py\n  \u003cconditional\u003e : if \u003cexpr\u003e then \u003cexpr\u003e (if \u003cexpr\u003e then \u003cexpr\u003e)* otherwise \u003cexpr\u003e -\u003e \u003cexpr\u003e\n  ```\n  ```sql\n  select if class = 0 then \"A\" if class = 1 then \"B\" else null\n  ```\n- `cast`: cast a column to either type `str`, `int`, or `float`.\n  ```py\n  cast : \u003ctype\u003e \u003cexpr\u003e -\u003e \u003cexpr\u003e\n  ```\n  ```sql\n  select cast str id\n  ```\n  - Cast the column \"id\" to type `str` and collect the result.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbanyc%2Fdfsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbanyc%2Fdfsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbanyc%2Fdfsql/lists"}