Skip to content

Instantly share code, notes, and snippets.

@aviatesk aviatesk/dfchain.jl

Created May 9, 2020
Embed
What would you like to do?
dataframe chaining while plotting
# what I will do here:
# - dataframe chain
# - keep to pass dataframe while plotting with `StatsPlots.@df`
# - pass columns names as variables
using DataFrames, Pipe, StatsPlots
theme(:juno)
df = DataFrame(x = randn(100), y = rand(Int, 100))
v1, v2 = :x, :y
v3 = :z
@pipe df |>
transform(_, [v1, v2] => ((x,y)->(x.*y)) => v3) |>
abs.(_) |>
(@df _ plot(cols(v2); label = ^(v2)); _) |> # keep to pass dataframe while plotting
@df _ plot!(cols(v3); yscale = :log10, label = ^(v3)) # more plotting
savefig("fig.png")
@aviatesk

This comment has been minimized.

Copy link
Owner Author

aviatesk commented May 9, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.