{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"series = 'SP115/10'"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/vnd.plotly.v1+html": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/vnd.plotly.v1+html": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import os\n",
"import pandas as pd\n",
"import series_details\n",
"import plotly.offline as py\n",
"py.init_notebook_mode()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(os.path.join('data', '{}.csv'.format(series.replace('/', '-'))), parse_dates=['start_date', 'end_date'])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"
National Archives of Australia: Series SP115/10
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Certificates Exempting from the provisions of 'The Influx of Chinese Restriction Act 1881'
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Total items | 6 |
---|
Access status | |
---|
Open | 6 (100.00%) |
Number of items digitised | 0 (0.00%) |
---|
Number of pages digitised | 0 |
---|
Date of earliest content | 1884 |
---|
Date of latest content | 1888 |
---|
Download the complete CSV file
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"series_details.display_summary(series, df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Content preview"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
" \n",
" \n",
" \n",
" | \n",
" identifier | \n",
" series | \n",
" control_symbol | \n",
" title | \n",
" contents_dates | \n",
" start_date | \n",
" end_date | \n",
" access_status | \n",
" location | \n",
" digitised_status | \n",
" digitised_pages | \n",
"
\n",
" \n",
" 0 | \n",
" 1826044 | \n",
" SP115/10 | \n",
" WHOLE SERIES | \n",
" Certificates Exempting from the provisions of 'The Influx of Chinese Restriction Act 1881' | \n",
" 1884 - 1888 | \n",
" 1884-01-01 00:00:00 | \n",
" 1888-01-01 00:00:00 | \n",
" Open | \n",
" Sydney | \n",
" False | \n",
" 0 | \n",
"
\n",
" 1 | \n",
" 11014873 | \n",
" SP115/10 | \n",
" 804 | \n",
" Ah Luck [box 1] | \n",
" 1884 - 1884 | \n",
" 1884-01-01 00:00:00 | \n",
" 1884-01-01 00:00:00 | \n",
" Open | \n",
" Sydney | \n",
" False | \n",
" 0 | \n",
"
\n",
" 2 | \n",
" 12145978 | \n",
" SP115/10 | \n",
" 800 | \n",
" Ah See [box 1] | \n",
" 1884 - 1884 | \n",
" 1884-01-01 00:00:00 | \n",
" 1884-01-01 00:00:00 | \n",
" Open | \n",
" Sydney | \n",
" False | \n",
" 0 | \n",
"
\n",
" 3 | \n",
" 12187508 | \n",
" SP115/10 | \n",
" 1092 | \n",
" Ah Gee [box 1] | \n",
" 1885 - 1885 | \n",
" 1885-01-01 00:00:00 | \n",
" 1885-01-01 00:00:00 | \n",
" Open | \n",
" Sydney | \n",
" False | \n",
" 0 | \n",
"
\n",
" 4 | \n",
" 12255210 | \n",
" SP115/10 | \n",
" 1643 | \n",
" Ah Kum [box 1] | \n",
" 1886 - 1886 | \n",
" 1886-01-01 00:00:00 | \n",
" 1886-01-01 00:00:00 | \n",
" Open | \n",
" Sydney | \n",
" False | \n",
" 0 | \n",
"
\n",
"
"
],
"text/plain": [
""
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Change the number_of_rows value to see more\n",
"number_of_rows = 5\n",
"\n",
"# Display dataframe \n",
"df[:number_of_rows].style.set_properties(['title'], **{'text-align': 'left'}).set_table_styles([dict(selector=\"th\", props=[(\"text-align\", \"center\")]),\n",
" dict(selector='.row_heading, .blank', props=[('display', 'none')])])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot content dates"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"data": [
{
"name": "Not digitised",
"type": "bar",
"x": [
1884,
1885,
1886,
1887,
1888
],
"y": [
3,
3,
2,
1,
1
]
}
],
"layout": {
"barmode": "stack",
"title": "Content dates",
"xaxis": {
"title": "Year"
},
"yaxis": {
"title": "Number of items"
}
}
},
"text/html": [
""
],
"text/vnd.plotly.v1+html": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = series_details.plot_dates(df)\n",
"py.iplot(fig, filename='series-dates-bar')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## View word frequencies"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# Combine all of the file titles into a single string\n",
"title_text = a = df['title'].str.lower().str.cat(sep=' ')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" \n",
" \n",
" | \n",
" word | \n",
" count | \n",
"
\n",
" \n",
" 8 | \n",
" ah | \n",
" 5 | \n",
"
\n",
" 10 | \n",
" box | \n",
" 5 | \n",
"
\n",
" 11 | \n",
" 1 | \n",
" 5 | \n",
"
\n",
" 0 | \n",
" certificates | \n",
" 1 | \n",
"
\n",
" 1 | \n",
" exempting | \n",
" 1 | \n",
"
\n",
" 2 | \n",
" provisions | \n",
" 1 | \n",
"
\n",
" 3 | \n",
" influx | \n",
" 1 | \n",
"
\n",
" 4 | \n",
" chinese | \n",
" 1 | \n",
"
\n",
" 5 | \n",
" restriction | \n",
" 1 | \n",
"
\n",
" 6 | \n",
" act | \n",
" 1 | \n",
"
\n",
" 7 | \n",
" 1881 | \n",
" 1 | \n",
"
\n",
" 9 | \n",
" luck | \n",
" 1 | \n",
"
\n",
" 12 | \n",
" see | \n",
" 1 | \n",
"
\n",
" 13 | \n",
" gee | \n",
" 1 | \n",
"
\n",
" 14 | \n",
" kum | \n",
" 1 | \n",
"
\n",
" 15 | \n",
" gow | \n",
" 1 | \n",
"
\n",
"
"
],
"text/plain": [
""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"series_details.display_word_counts(title_text)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" \n",
" \n",
" | \n",
" ngram | \n",
" count | \n",
"
\n",
" \n",
" 0 | \n",
" box 1 | \n",
" 5 | \n",
"
\n",
" 1 | \n",
" 1 ah | \n",
" 4 | \n",
"
\n",
" 2 | \n",
" restriction act | \n",
" 1 | \n",
"
\n",
" 3 | \n",
" ah see | \n",
" 1 | \n",
"
\n",
" 4 | \n",
" certificates exempting | \n",
" 1 | \n",
"
\n",
" 5 | \n",
" act 1881 | \n",
" 1 | \n",
"
\n",
" 6 | \n",
" from the | \n",
" 1 | \n",
"
\n",
" 7 | \n",
" ah luck | \n",
" 1 | \n",
"
\n",
" 8 | \n",
" ah gee | \n",
" 1 | \n",
"
\n",
" 9 | \n",
" gow box | \n",
" 1 | \n",
"
\n",
" 10 | \n",
" luck box | \n",
" 1 | \n",
"
\n",
" 11 | \n",
" influx of | \n",
" 1 | \n",
"
\n",
" 12 | \n",
" see box | \n",
" 1 | \n",
"
\n",
" 13 | \n",
" the provisions | \n",
" 1 | \n",
"
\n",
" 14 | \n",
" ah kum | \n",
" 1 | \n",
"
\n",
" 15 | \n",
" ah gow | \n",
" 1 | \n",
"
\n",
" 16 | \n",
" provisions of | \n",
" 1 | \n",
"
\n",
" 17 | \n",
" 'the influx | \n",
" 1 | \n",
"
\n",
" 18 | \n",
" chinese restriction | \n",
" 1 | \n",
"
\n",
" 19 | \n",
" of chinese | \n",
" 1 | \n",
"
\n",
" 20 | \n",
" kum box | \n",
" 1 | \n",
"
\n",
" 21 | \n",
" gee box | \n",
" 1 | \n",
"
\n",
" 22 | \n",
" 1881 ah | \n",
" 1 | \n",
"
\n",
" 23 | \n",
" exempting from | \n",
" 1 | \n",
"
\n",
" 24 | \n",
" of 'the | \n",
" 1 | \n",
"
\n",
"
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Change ngram_count for larger ngrams (trigrams etc)\n",
"ngram_count = 2\n",
"series_details.display_top_ngrams(title_text, ngram_count)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}