Summing rows and renaming the resultant column in one 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 :stuck_out_tongue:
so simple and obvious when you know1