# Is there a better way to do this? many calculated columns

**URL:** <https://discourse.julialang.org/t/is-there-a-better-way-to-do-this-many-calculated-columns/47111>\
**Category:** General Usage\
**Created:** [September 23, 2020, 5:33am UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-do-this-many-calculated-columns/47111 "2020-09-23T05:33:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mariok90](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mariok90/32/7076_2.png) [@mariok90](https://discourse.julialang.org/u/mariok90)\
**Post date:** [September 23, 2020, 8:11am UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-do-this-many-calculated-columns/47111/5 "2020-09-23T08:11:03Z")

</div>

You can also construct DataFrames with NamedTuples:

```julia
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.

```julia
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/is-there-a-better-way-to-do-this-many-calculated-columns/47111)._
