In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
In [2]:
df = pd.read_json('Topwords_abstract_bypage_v4.json')
In [3]:
df.head()
Out[3]:
In [4]:
page1 = df[df['pagegroup']==1]
In [27]:
page1.groupby('word')['year'].count().reset_index().sort(columns='year',ascending=False)[25:75]
Out[27]:
In [16]:
plt.plot(df[df['word']=='British']['year'],df[df['word']=='British']['value'], sns.xkcd_rgb["denim blue"],
label = 'British')
plt.plot(df[df['word']=='Chinese']['year'],df[df['word']=='Chinese']['value'], sns.xkcd_rgb["pale red"],
label = 'Chinese')
plt.xlabel('Year')
plt.ylabel('Count')
plt.title('The Fall of "British" and the Rise of "Chinese"')
plt.legend(loc='upper right')
sns.set_style('white')
sns.despine()
plt.savefig('BritishChinese.pdf')
In [32]:
plt.plot(df[df['word']=='steamer']['year'],df[df['word']=='steamer']['value'])
plt.plot(df[df['word']=='Wharf']['year'],df[df['word']=='Wharf']['value'], color='red')
plt.plot(df[df['word']=='tons']['year'],df[df['word']=='tons']['value'], color='green')
plt.plot(df[df['word']=='bark']['year'],df[df['word']=='bark']['value'], color='purple')
plt.plot(df[df['word']=='ship']['year'],df[df['word']=='ship']['value'], color='pink')
Out[32]:
In [26]:
plt.plot(df[df['word']=='minister']['year'],df[df['word']=='minister']['value'])
Out[26]:
In [ ]:
plt.plot(df[df['word']=='Rubber']['year'],df[df['word']=='Rubber']['value'], sns.xkcd_rgb["greyish"],
label = 'Rubber')
plt.plot(df[df['word']=='Pepper']['year'],df[df['word']=='Pepper']['value'], sns.xkcd_rgb["faded green"],
label = 'Pepper')
plt.xlabel('Year')
plt.ylabel('Count')
plt.title("Singapore's Transition from Agriculture")
plt.legend(loc='upper right')
sns.set_style('white')
sns.despine()
plt.savefig('BritishChinese.pdf')