[julia-users] Re: DataFrame Manipulation (like dplyr) Help

2016-08-26 Thread jtwatkin
Thanks--going to take a look at new package, jplyr.jl, that tshort 
mentioned.  Maybe what I'm looking for already exits.

On Friday, August 26, 2016 at 2:42:01 PM UTC-4, Evan Fields wrote:
>
> I'm not sure if you'll find this any cleaner, but maybe something like
>
> function summary2(df, queries...)
>   d = Dict()
>   for query in queries
> name = query[1]
> f = query[2]
> col = query[3]
> d[name] = f(df[col])
>   end
>   return d
> end
>
> Which could be used e.g.
>
> julia> summary2(dat, ("mu_x", mean, :x), ("std_y", std, :y))
> Dict{Any,Any} with 2 entries:
>   "std_y" => 0.338854
>   "mu_x"  => 0.438158
>
> julia>
>
> Admittedly this is less flexible, but perhaps more transparent. 
>


[julia-users] Re: DataFrame Manipulation (like dplyr) Help

2016-08-26 Thread Evan Fields
I'm not sure if you'll find this any cleaner, but maybe something like

function summary2(df, queries...)
  d = Dict()
  for query in queries
name = query[1]
f = query[2]
col = query[3]
d[name] = f(df[col])
  end
  return d
end

Which could be used e.g.

julia> summary2(dat, ("mu_x", mean, :x), ("std_y", std, :y))
Dict{Any,Any} with 2 entries:
  "std_y" => 0.338854
  "mu_x"  => 0.438158

julia>

Admittedly this is less flexible, but perhaps more transparent.