I am summing rows of selected columns in a dataframe to create a new column
df2 = select(df, :band_result, Cols(r"rslt") => +)
then renaming the column to “sum”.
rename!(df2, 2 => :sum)
Is there a way to do this in a single step?
I am summing rows of selected columns in a dataframe to create a new column
df2 = select(df, :band_result, Cols(r"rslt") => +)
then renaming the column to “sum”.
rename!(df2, 2 => :sum)
Is there a way to do this in a single step?
Absolutely, sometimes you need parentheses to make the PEMDAS work.
select(df, r"rslt" => (+) => :sum)
@pdeffebach thankyou so much, I tried parentheses everywhere, just not there
so simple and obvious when you know1