Fire up GraphLab Create


In [ ]:
import graphlab

Load a tabular data set


In [ ]:
sf = graphlab.SFrame('people-example.csv')

SFrame basics


In [ ]:
# We can view first few lines of the table
sf.head()

In [ ]:
sf.tail()

GraphLab Canvas


In [ ]:
# Take any data structure in graphlab Create
sf.show()

In [ ]:
graphlab.canvas.set_target('ipynb')

In [ ]:
sf['age'].show(view='Categorical')

Inspect columns of datasets


In [ ]:
sf['Country']

In [ ]:
sf['age']

In [ ]:
sf['age'].mean()

In [ ]:
sf['age'].max()

Create new columns in our SFrame


In [ ]:
sf

In [ ]:
sf['Full Name'] = sf['First Name'] + sf['Last Name']

In [ ]:
sf

In [ ]:
sf['age'] * sf['age']

Use the apply function to do data transformation


In [ ]:
sf['Country']

In [ ]:
sf['Country'].show()

In [ ]:
def transformCountry(country):
    if country == "USA":
        return "United States"
    else:
        return country

transformCountry("USA")

In [ ]:
sf['Country'].apply(transformCountry)

In [ ]:
sf['Country'] = sf['Country'].apply(transformCountry)

In [ ]:
sf