Tool Walkthroughs




Pay Notebook Creator: Roy Hyunjin Han0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Plot Name Frequency By Year

Given baby names by year of birth, plot the frequency of a specific name by year.

Thanks to the U.S. Social Security Administration for providing this dataset of baby names from 1910 to 2016.

In [ ]:
# Click the Blue Plane to transform this into a CrossCompute Tool
name_table_path = 'Datasets/names-by-year.csv'
name = 'louisa'
target_folder = '/tmp'
In [ ]:
from pandas import read_csv
name_table = read_csv(name_table_path)
name_table[:5]
In [ ]:
name = name.capitalize().split()[0]
name
In [ ]:
selected_name_table = name_table[name_table.name == name]
selected_count_by_year = selected_name_table.groupby('year')['count'].sum()
selected_count_by_year[:5]
In [ ]:
%matplotlib inline
axes = selected_count_by_year.plot(legend=False, title='Name Frequency by Year of Birth: ' + name)
In [ ]:
from os.path import join
target_path = join(target_folder, 'name-by-year.png')
axes.get_figure().savefig(target_path);
print('name_by_year_image_path = ' + target_path)