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

ayodyas
Tue, 06 Sep 2022 12:45:18 +0000
General Usage

I have a dataframe df,

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

I wanted to calculate the sum of specific columns (p1 and p2) and append it as the last row in respective columns (zero on other locations). I wanted to get like

  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

4 posts - 4 participants