In [1]:
import graphlab
In [3]:
sf = graphlab.SFrame('people-example.csv')
In [5]:
sf.head()# view few lines of the table
Out[5]:
In [6]:
sf.show()
In [7]:
graphlab.canvas.set_target('ipynb')
In [8]:
sf['age'].show(view='Categorical')
In [9]:
sf['Country']
Out[9]:
In [10]:
sf['age']
Out[10]:
In [11]:
sf['age'].mean()
Out[11]:
In [12]:
sf['age'].max()
Out[12]:
In [13]:
sf
Out[13]:
In [14]:
sf['Full Name'] = sf['First Name'] + ' ' + sf['Last Name']
In [15]:
sf
Out[15]:
In [16]:
sf['Country']
Out[16]:
In [18]:
sf['Country'].show()
In [19]:
def transformCountry(country):
if country == 'USA':
return "United States"
else:
return country
In [21]:
transformCountry('USA')
Out[21]:
In [23]:
sf['Country'].apply(transformCountry)
Out[23]:
In [24]:
sf['Country']
Out[24]:
In [25]:
sf['Country'] = sf['Country'].apply(transformCountry)
In [26]:
sf
Out[26]:
In [ ]: