Sum of columns in julia dataframe and appen it as last element in the respective columns

Here is one solution

julia> df = DataFrame(p1 = [1, 2, 3, 4, 5],p2 = [10,20,30,40,50],p3 = [5,5,10,20,20]);

julia> function push_sums!(df, cols)           
           d = Dict(names(df) .=> 0) 
           for col in cols
               d[col] = sum(df[:, col])
           end
           push!(df, d)
       end;

julia> push_sums!(df, ["p1", "p2"])6×3 DataFrame
 Row │ p1     p2     p3    
     │ Int64  Int64  Int64 
─────┼─────────────────────
   1 │     1     10      5
   2 │     2     20      5
   3 │     3     30     10
   4 │     4     40     20
   5 │     5     50     20
   6 │    15    150      0
2 Likes