25个版本 (10个破坏性更新)
| 0.11.0 | 2024年6月28日 |
|---|---|
| 0.10.1 | 2024年5月23日 |
| 0.6.2 | 2024年1月9日 |
| 0.3.5 | 2023年12月23日 |
在数据库实现中排名39
285KB
2K SLoC
dfsql

- 修订:将独立的
count命令替换为len,因此请确保将count()和col "count"分别替换为len和col "len"。- 一元
count <col>命令不受影响。
- 一元
安装
cargo install dfsql
如何运行
dfsql --input your.csv --output a-new.csv
# ...or
dfsql -i your.csv -o a-new.csv
REPL
exit/quit:退出REPL循环。exitundo:撤销之前的成功操作。undoreset:重置所有更改并回到原始数据框。resetschema:显示数据框的列名和类型。schemasave:将当前数据框保存到文件。save a-new.csv
语句
selectselect <expr>*select last_name first_name- 选择列"last_name"和"first_name",并将它们收集到一个数据框中。
- Group by
group (<col> | <var>)* agg <expr>*group first_name agg (count)- 按列"first_name"对数据框进行分组,然后对每个组使用成员计数进行聚合。
filterfilter <expr>filter first_name = "John"limitlimit <int>limit 5reversereversesortsort ((asc | desc | ()) <col>)*sort icpsr_iduseuse <var>use other- 切换到名为
other的数据框。
- 切换到名为
- join
(left | right | inner | full) join <var> on <col> <col>?left join other on id ID- 在名为
other的数据框上执行左连接,基于我的列id和其列ID。
- 在名为
表达式
col:对列的引用。col : (<str> | <var>) -> <expr>select col first_nameexclude:从数据框中删除列。exclude : <expr>* -> <expr>select exclude last_name first_name- 文字值:如
42、"John"、1.0和null。 - 二元运算符
select a * b- 计算列"a"和"b"的乘积并将结果收集。
- 一元运算符
select -aselect sum a- 计算列"a"中所有值的总和并收集标量结果。
alias:为列分配名称。alias : (<col> | <var>) <expr> -> <expr>select alias product a * b- 将乘积命名为"product"并收集新列。
- 条件运算符
<conditional> : if <expr> then <expr> (if <expr> then <expr>)* otherwise <expr> -> <expr>select if class = 0 then "A" if class = 1 then "B" else null cast:将列转换为以下类型之一str、int或float。cast : <type> <expr> -> <expr>select cast str id- 将 "id" 列转换为
str类型并收集结果。
- 将 "id" 列转换为
依赖关系
~20–51MB
~871K SLoC