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?