UndefVarError: .* not defined when grouping with DataframesMeta

Hello all,

I ran into a problem when running a Julia script. The following code produces an error:

UndefVarError: .* not defined

The offending Code:

    group = groupby(my_dataframe, [:COLUMN_1, :COLUMN_2])
    better_df = @combine(group, :NEW_COLUMN = sum(:COLUMN_4 .* :COLUMN_5))

What I am trying to do is group by two columns and sum the product of two other columns when grouping. It is unclear to me why I get the UndefVarError. My understanding is that the .* operator will multiply the values in the two columns row by row. Am I missing something?

If you write instead

better_df = @combine(group, :NEW_COLUMN = (:COLUMN_4 .* :COLUMN_5) |> sum)

It will work. That being said, this looks like a bug, so I would file an issue over at DataFramesMeta

1 Like

x-ref: operators do not work inside function call inside macros · Issue #352 · JuliaData/DataFramesMeta.jl · GitHub
This is fixed on master branch.

CC @pdeffebach

This also does not work:

@select df :grade_100 = :grade .∗ 10
ERROR: UndefVarError: ∗ not defined

from “Julia Data Science” by Storopoli et al

I apologize for this,

We have a new release out which fixes this bug.

1 Like

This fixed the issue for now. I also confirmed the results of the calculations are accurate to 14 decimal places.

1 Like