{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Load UCI census and convert to json for sending to the visualization\n",
"import pandas as pd\n",
"features = [\"Age\", \"Workclass\", \"fnlwgt\", \"Education\", \"Education-Num\", \"Martial Status\",\n",
" \"Occupation\", \"Relationship\", \"Race\", \"Sex\", \"Capital Gain\", \"Capital Loss\",\n",
" \"Hours per week\", \"Country\", \"Target\"]\n",
"jsonstr = pd.read_csv(\n",
" \"https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.test\",\n",
" names=features,\n",
" sep=r'\\s*,\\s*',\n",
" engine='python',\n",
" skiprows=[0],\n",
" na_values=\"?\").to_json(orient='records')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Display the Dive visualization for this data\n",
"from IPython.core.display import display, HTML\n",
"\n",
"HTML_TEMPLATE = \"\"\"\n",
" \n",
" \"\"\"\n",
"html = HTML_TEMPLATE.format(jsonstr=jsonstr)\n",
"display(HTML(html))"
]
}
],
"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.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}