1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
open Ast
(*
--# Remove grouping
--#
--# Removes the grouping structure from a DataFrame.
--#
--# @name ungroup
--# @param df :: DataFrame The input DataFrame.
--# @return :: DataFrame An ungrouped DataFrame.
--# @example
--# ungroup(df)
--# @family colcraft
--# @seealso group_by
--# @export
*)
let register env =
Env.add "ungroup"
(make_builtin ~name:"ungroup" 1 (fun args _env ->
match args with
| [VDataFrame df] ->
VDataFrame { df with group_keys = [] }
| [_] -> Error.type_error "Function `ungroup` expects a DataFrame as first argument."
| _ -> Error.make_error ArityError "Function `ungroup` takes exactly 1 argument."
))
env