Sum() one column in dataframe

Hi,

This is the structure of the dataframe:

  Row │ NAMES        NAMES_NUMBER  P_NUMBER_NAMES  P_NUMBER_NUMBERS  TOTAL  
      │ String       Int64         Int64           Int64             Int64  
──────┼─────────────────────────────────────────────────────────────────────
    1 │ ADA                     6              11                 1       6
    2 │ ABE                     8               6                 2      16
    3 │ BEA                     8             416                 3      24
    4 │ ED                      9            1354                 4      36
    5 │ HA                      9            1889                 5      45
  ⋮   │      ⋮            ⋮              ⋮                ⋮            ⋮
 5160 │ MARYLOUISE            138            3381              5160  712080
 5161 │ CHRISTOPHER           139             862              5161  717379
 5162 │ KRISTOPHER            139            2687              5162  717518
 5163 │ SYLVESTER             145            4598              5163  748635

I want this (I write it in select since that is what makes the most sense to me):

select SUM(total) from df

Wat is the dataframe equivalent of this?

thanks,

sum(df[!,:TOTAL])

where df is your DataFrame.

I get this error:

ERROR: LoadError: syntax: extra token "names" after end of expression
Stacktrace:
 [1] top-level scope at c:\Users\achen\Desktop\Julia\Visual Basic Code\EULER22.jl:4
in expression starting at c:\Users\achen\Desktop\Julia\Visual Basic Code\EULER22.jl:4

can you show your code? you should be able to just:

sum(df.TOTAL)

Hi,

I see the problem.

the last transform doesn’t save the transformation. it only changes it at that time. I gave it the name df and it worked!

thanks @jling and @oheil

df = DataFrame(NAMES=sort(a))
df.NAMES_NUMBER = count_char.(df.NAMES)
df.P_NUMBER_NAMES = 1:nrow(df)
sort!(df, :NAMES_NUMBER)
df.P_NUMBER_NUMBERS = 1:nrow(df)

@transform df @byrow begin
    :TOTAL =:P_NUMBER_NUMBERS*:NAMES_NUMBER
end