# Summing rows and renaming the resultant column in one step?

**URL:** <https://discourse.julialang.org/t/summing-rows-and-renaming-the-resultant-column-in-one-step/60715>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [May 7, 2021, 1:40pm UTC](https://discourse.julialang.org/t/summing-rows-and-renaming-the-resultant-column-in-one-step/60715 "2021-05-07T13:40:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geoffysicist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/geoffysicist/32/24859_2.png) [@Geoffysicist](https://discourse.julialang.org/u/Geoffysicist)\
**Post date:** [May 7, 2021, 1:40pm UTC](https://discourse.julialang.org/t/summing-rows-and-renaming-the-resultant-column-in-one-step/60715/1 "2021-05-07T13:40:26Z")

</div>

I am summing rows of selected columns in a dataframe to create a new column

```julia
df2 = select(df, :band_result, Cols(r"rslt") => +)

```

then renaming the column to “sum”.

```julia
rename!(df2, 2 => :sum)

```

Is there a way to do this in a single step?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/a/1ab42b4853429b13cafca2b8cb31e9dce6f43594.png)

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [May 7, 2021, 1:45pm UTC](https://discourse.julialang.org/t/summing-rows-and-renaming-the-resultant-column-in-one-step/60715/2 "2021-05-07T13:45:01Z")

</div>

Absolutely, sometimes you need parentheses to make the PEMDAS work.

```julia
select(df, r"rslt" => (+) => :sum)

```

---

<div class="post-metadata">

**Author:** ![Geoffysicist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/geoffysicist/32/24859_2.png) [@Geoffysicist](https://discourse.julialang.org/u/Geoffysicist)\
**Post date:** [May 7, 2021, 1:48pm UTC](https://discourse.julialang.org/t/summing-rows-and-renaming-the-resultant-column-in-one-step/60715/3 "2021-05-07T13:48:16Z")

</div>

@pdeffebach thankyou so much, I tried parentheses everywhere, just not there 😛  
so simple and obvious when you know1
