graphlab SFrame sum all values in a column
<p>How to sum all values in a column of SFrame graphlab. I tried looking  into the official documentation and it is given only for SaArray(<a href="https://turi.com/products/create/docs/generated/graphlab.SArray.sum.html#graphlab.SArray.sum" rel="nofollow">doc</a>)
without any example.</p>

<p>I think the question from the op was more about how to do this across all (or a list of) columns at once.  Here's the comparison between pandas and graphlab.</p>

<pre><code># imports
import graphlab as gl    
import pandas as pd
import numpy as np

# generate data
data = np.random.randint(0,10,size=100).reshape(10,10)
col_names = list('ABCDEFGHIJ')

# make dataframe and sframe
df = pd.DataFrame(data, columns=names)
sf = graphlab.SFrame(df)

# get sum for all columns (pandas).  Returns a series.
df.sum().sort_values(ascending=False)

D    65
A    61
J    59
B    50
H    46
G    46
I    45
F    43
C    37
E    36

# sf.sum() does not work
# get sum for each of the columns (graphlab)
for col in col_names:
    print col, sf[col].sum()

A 61
B 50
C 37
D 65
E 36
F 43
G 46
H 46
I 45
J 59
</code></pre>

<p>I had the same question. Pandas provides an easy interface to apply an aggregating function across rows or columns of a dataframe.  Could not find the same for a SFrame?  Only way I could think to do it was to iterate on a list of columns.   </p>

<p>Is there a better way?</p>

python graphlab