# Nested Pipes

**URL:** https://discourse.julialang.org/t/nested-pipes/49573
**Category:** General Usage
**Tags:** package
**Created:** [November 4, 2020, 10:15am UTC](https://discourse.julialang.org/t/nested-pipes/49573 "2020-11-04T10:15:24Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)
#### Post date: [November 5, 2020, 5:06am UTC](https://discourse.julialang.org/t/nested-pipes/49573/5 "2020-11-05T05:06:03Z")

</div>

Thanks Lyndon.  
I couldn’t see any examples of packages in the list doing this. Underscores.jl is probably closest.

For background. I like Pipes because I prefer to read logic left-to-right and not have nested brackets.  
I also use them to add many columns to a DataFrame. Nested example below.

```julia
using DataFrames, Pipe, DotMaps, NamedTupleTools

df = DataFrame(a = rand(10))

@pipe eachrow(df) .|> begin  
    r = DotMap(convert(Dict,NamedTuple(_)))    

    r.New = r.a * 2
    r.New2 = r.New + 10
    # ...

    r.New20 = @pipe r.a |> sqrt |> log(__,2) #nested pipe using__
    
    r
end |> DataFrame

```

btw. I’ve used this example in other questions and its not very popular though I still like it.

> [@Piping DataFrame rows](https://discourse.julialang.org/t/piping-dataframe-rows/49576/6):
>
> I was thinking the same thing too.

> [@Is there a better way to do this? many calculated columns](https://discourse.julialang.org/t/is-there-a-better-way-to-do-this-many-calculated-columns/47111/5):
>
> You can also construct DataFrames with NamedTuples: DataFrame( (col\_1 = i, col\_2 = i^2, col\_3 = i^2 + 10) for i in 1:100 ) For more complex operations you could define functions beforehand. func1(x) = x^2 func2(x) = func1(x) + 10 DataFrame( (col\_1 = i, col\_2 = func1(i), col\_3 =func2(i)) for i in 1:100 )

---

_[View the full topic](https://discourse.julialang.org/t/nested-pipes/49573)._
