Prashant Bhanarkar Prashant Bhanarkar - 3 months ago 120
Python Question

graphlab SFrame sum all values in a column

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(doc)
without any example.

Answer
>>> import graphlab as gl
>>> sf = gl.SFrame({'foo':[1,2,3], 'bar':[4,5,6]})
>>> sf
Columns:
        bar     int
        foo     int

Rows: 3

Data:
+-----+-----+
| bar | foo |
+-----+-----+
|  4  |  1  |
|  5  |  2  |
|  6  |  3  |
+-----+-----+
[3 rows x 2 columns]
>>> sf['foo'].sum()
6