In [ ]:
import graphlab
In [1]:
sf = graphlab.SFrame('people-example.csv')
In [ ]:
sf #we can view first few lines of table
In [ ]:
sf.tail() # view end of the table
In [ ]:
# .show() visualizes any data structure in GraphLab Create
sf.show()
In [ ]:
# If you want Canvas visualization to show up on this notebook,
# rather than popping up a new window, add this line:
graphlab.canvas.set_target('ipynb')
In [ ]:
sf['age'].show(view='Categorical')
In [ ]:
sf['Country']
In [ ]:
sf['age']
Some simple columnar operations
In [ ]:
sf['age'].mean()
In [ ]:
sf['age'].max()
In [ ]:
sf
In [ ]:
sf['Full Name'] = sf['First Name'] + ' ' + sf['Last Name']
In [ ]:
sf
In [ ]:
sf['age'] * sf['age']
In [ ]:
sf['Country']
In [ ]:
sf['Country'].show()
In [ ]:
def transform_country(country):
if country == 'USA':
return 'United States'
else:
return country
In [ ]:
transform_country('Brazil')
In [ ]:
transform_country('Brasil')
In [ ]:
transform_country('USA')
In [ ]:
sf['Country'].apply(transform_country)
In [ ]:
sf['Country'] = sf['Country'].apply(transform_country)
In [ ]:
sf
In [ ]: