mhanberg
Creator of elixir-tools
Using Series.filter inside DataFrame.summarise
Are you able to use Explorer.Series.filter inside Explorer.DataFrame.summarise ?
I currently have some code that looks like this, but its giving me a compiler error about (ArgumentError) expected a variable to be given to var!, got: Explorer.DataFrame.pull( var!(df, Explorer.Query), :df )
data_frame
|> DataFrame.mutate(
foo_id:
if result in ["alice", "bob", "carol", "dave"] do
bar_id
else
nil
end
)
|> DataFrame.group_by(["some_idx"])
|> DataFrame.summarise(
baz:
if count(foo_id) == 0 do
"other/none"
else
first(filter(foo_id, is_not_nil(_)))
end
)
Marked As Solved
mhanberg
Creator of elixir-tools
Okay, ended up figuring it out using a different approach.
some_idx = data_frame |> DataFrame.distinct([:some_idx])
data_frame
|> DataFrame.mutate(
foo_id:
if result in ["alice", "bob", "carol", "dave"] do
foo_id
else
nil
end
)
|> DataFrame.drop_nil([:foo_id])
|> DataFrame.group_by(["some_idx"])
|> DataFrame.summarise(foo: first(foo_id))
|> DataFrame.join(some_idx, on: [:some_idx], how: :right)
|> DataFrame.mutate(foo: fill_missing(foo, "none"))
Popular in Questions
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project.
Baby step #1 is extracting the number ...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217
Let’s say I have a map with required and optional k...
New
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir
iex(2)...
New
Other popular topics
can someone please explain to me how Enum.reduce works with maps
New
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New







