In [1]:
%matplotlib inline
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
In [2]:
# Load dataset
import zipfile
with zipfile.ZipFile('../datasets/baby-names2.csv.zip', 'r') as z:
f = z.open('baby-names2.csv')
names = pd.io.parsers.read_table(f, sep=',')
In [3]:
names.head()
Out[3]:
In [4]:
names[names.year == 1993].head()
Out[4]:
In [5]:
boys = names[names.sex == 'boy'].copy()
girls = names[names.sex == 'girl'].copy()
In [6]:
william = boys[boys['name']=='William']
plt.plot(range(william.shape[0]), william['prop'])
plt.xticks(range(william.shape[0])[::5], william['year'].values[::5], rotation='vertical')
plt.ylim([0, 0.1])
plt.show()
In [7]:
Daniel = boys[boys['name']=='Daniel']
plt.plot(range(Daniel.shape[0]), Daniel['prop'])
plt.xticks(range(Daniel.shape[0])[::5], Daniel['year'].values[::5], rotation='vertical')
plt.ylim([0, 0.1])
plt.show()
In [ ]:
In [ ]:
In [ ]: