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

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
)
1 Like