fireproofsocks

fireproofsocks

Explorer.DataFrame.mutate_with example?

I’m really enjoying taking a look at the fantastic Explorer package and seeing how it lines up to Pandas DataFrames.

One common task is to clean up fields in a column, e.g. converting currency values from strings to floats. I’ve been able to do this using Explorer.Series.transform/2 and Explorer.DataFrame.put/3:

df = Explorer.DataFrame.new(%{"Price" => ["$5,555.55", "$4,444.44", "$6,666.66"]})
Explorer.DataFrame.put(df, "Price", 
  Explorer.Series.transform(df["Price"], 
    fn "$" <> n -> n |> String.replace(",", "") |> Float.parse() |> elem(0)
  end))

So far, I’m unable to come up with a valid callback for the Explorer.DataFrame.mutate_with/3. I’m not entirely sure what the “Lazy Frame” is or what a function there needs to receive. Can someone demonstrate an example of mutate_with using a callback function like the one I used above?

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
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
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement