I’m new to Elixir (with a background in R) and tinkering with Explorer so I’m probably missing something obvious here.
For this example, we will create a simple dataframe and add a boolean flag.
df = Explorer.DataFrame.new(group: ["A", "B", "B", "C"], value: 1..4)
|> DF.mutate(flag: Explorer.Series.less(value, 3))
I can sum across the boolean series like this…
Explorer.Series.sum(df[:flag])
But when I try to incorporate that in a group_by
and summarise
df
|> Explorer.DataFrame.group_by("group")
|> Explorer.DataFrame.summarise(flag_count: sum(flag))
I get this error
#Inspect.Error<
got FunctionClauseError with message:
"""
no function clause matching in Explorer.PolarsBackend.Shared.normalise_dtype/1
"""
while inspecting:
%{
__struct__: Explorer.DataFrame,
data: %Explorer.PolarsBackend.DataFrame{resource: #Reference<0.3997017276.1149894680.178408>},
dtypes: %{"flag_count" => :boolean, "group" => :string},
groups: [],
names: ["group", "flag_count"]
}
Stacktrace:
(explorer 0.5.6) lib/explorer/polars_backend/shared.ex:129: Explorer.PolarsBackend.Shared.normalise_dtype("u32")
(explorer 0.5.6) lib/explorer/polars_backend/shared.ex:75: Explorer.PolarsBackend.Shared.create_series/1
(explorer 0.5.6) lib/explorer/data_frame.ex:3171: Explorer.DataFrame.pull_existing/2
(explorer 0.5.6) lib/explorer/data_frame.ex:342: Explorer.DataFrame.fetch/2
(elixir 1.14.4) lib/access.ex:288: Access.get/3
(explorer 0.5.6) lib/explorer/backend/data_frame.ex:228: anonymous fn/6 in Explorer.Backend.DataFrame.inspect/5
(elixir 1.14.4) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
(explorer 0.5.6) lib/explorer/backend/data_frame.ex:227: Explorer.Backend.DataFrame.inspect/5
What am I missing?