{ "metadata": { "name": "", "signature": "sha256:1c5ebb89730c3c64ce189e47c46f85bda5aba6b6f46bb20465c33a3b05106385" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "##Context:\n", "\n", "According to [NPR.org](http://www.npr.org/blogs/money/2015/02/11/384988128/the-fall-and-rise-of-u-s-inequality-in-2-graphs), \"After 1980, only the top 1% saw their incomes rise.\" [Flowing Data](http://flowingdata.com/2015/02/20/top-1-earners-versus-bottom-90/) quoted this figure:\n", "\n", "![](http://flowingdata.com/wp-content/uploads/2015/02/Earners-620x560.png)\n", "\n", "Another figure:\n", "\n", "![](http://aflyax.github.io/images/income_growth.png)\n", "\n", "Their source came from [World Top Incomes Database](http://topincomes.parisschoolofeconomics.eu/#Database).\n", "\n", "I decided to double-check it using a [dataset](https://www.census.gov/hhes/www/income/data/historical/families/2013/f03AR.xls) from census.gov" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import pandas as pd\n", "import seaborn as sns\n", "sns.set(context=\"poster\", style=\"dark\")\n", "import mpld3\n", "import pylab as pl" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 43 }, { "cell_type": "code", "collapsed": false, "input": [ "# csv location = https://github.com/aflyax/Python/blob/master/income/income_2013_dollars.csv\n", "income_df = pd.read_csv(\"income_2013_dollars.csv\", sep='\\t', thousands=',')\n", "income_df.columns = [\"year\", \"lowest fifth\", \"second fifth\", \"third fifth\", \"fourth fifth\", \"top fifth\", \"top 5%\"]\n", "income_df.sort(columns=\"year\", inplace=True)\n", "income_df.head()" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yearlowest fifthsecond fifththird fifthfourth fifthtop fifthtop 5%
47 1966 14747 32739 46844 62710 107026 164340
46 1967 14977 33490 48138 64560 113997 180362
45 1968 16143 35208 50300 67270 114947 177194
44 1969 16656 36783 52635 70510 120757 185476
43 1970 16404 36271 52445 70744 121652 185243
\n", "
" ], "metadata": {}, "output_type": "pyout", "prompt_number": 57, "text": [ " year lowest fifth second fifth third fifth fourth fifth top fifth \\\n", "47 1966 14747 32739 46844 62710 107026 \n", "46 1967 14977 33490 48138 64560 113997 \n", "45 1968 16143 35208 50300 67270 114947 \n", "44 1969 16656 36783 52635 70510 120757 \n", "43 1970 16404 36271 52445 70744 121652 \n", "\n", " top 5% \n", "47 164340 \n", "46 180362 \n", "45 177194 \n", "44 185476 \n", "43 185243 " ] } ], "prompt_number": 57 }, { "cell_type": "code", "collapsed": false, "input": [ "income_df.tail()" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yearlowest fifthsecond fifththird fifthfourth fifthtop fifthtop 5%
4 2009 16604 40232 65061 98788 205788 352985
3 2010 15944 39436 64276 98064 199918 334275
2 2011 15828 38898 63212 96563 205003 356839
1 2012 15760 38739 63372 96861 205503 357458
0 2013 16109 39514 63916 97207 206687 358722
\n", "
" ], "metadata": {}, "output_type": "pyout", "prompt_number": 50, "text": [ " year lowest fifth second fifth third fifth fourth fifth top fifth \\\n", "4 2009 16604 40232 65061 98788 205788 \n", "3 2010 15944 39436 64276 98064 199918 \n", "2 2011 15828 38898 63212 96563 205003 \n", "1 2012 15760 38739 63372 96861 205503 \n", "0 2013 16109 39514 63916 97207 206687 \n", "\n", " top 5% \n", "4 352985 \n", "3 334275 \n", "2 356839 \n", "1 357458 \n", "0 358722 " ] } ], "prompt_number": 50 }, { "cell_type": "code", "collapsed": false, "input": [ "ax = income_df.plot(x=\"year\")\n", "ax.set_ylabel(\"income\")\n", "ax.set_xlabel(\"year\")\n", "print(\"feel free to interact with the graph:\")\n", "fig = pl.gcf()\n", "mpld3.display()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "feel free to interact with the graph:\n" ] }, { "html": [ "\n", "\n", "\n", "\n", "
\n", "" ], "metadata": {}, "output_type": "pyout", "prompt_number": 60, "text": [ "" ] } ], "prompt_number": 60 }, { "cell_type": "code", "collapsed": false, "input": [ "mpld3.save_html(fig, \"fig.html\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 62 }, { "cell_type": "code", "collapsed": false, "input": [ "income_df[income_df.year.isin([1970, 2000, 2013])]" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yearlowest fifthsecond fifththird fifthfourth fifthtop fifthtop 5%
43 1970 16404 36271 52445 70744 121652 185243
13 2000 19103 43678 68646 101170 212266 376138
0 2013 16109 39514 63916 97207 206687 358722
\n", "
" ], "metadata": {}, "output_type": "pyout", "prompt_number": 84, "text": [ " year lowest fifth second fifth third fifth fourth fifth top fifth \\\n", "43 1970 16404 36271 52445 70744 121652 \n", "13 2000 19103 43678 68646 101170 212266 \n", "0 2013 16109 39514 63916 97207 206687 \n", "\n", " top 5% \n", "43 185243 \n", "13 376138 \n", "0 358722 " ] } ], "prompt_number": 84 }, { "cell_type": "markdown", "metadata": {}, "source": [ "###Slightly different story from \"after 1980, only the top 1% saw their incomes rise\".\n", "\n", "This is all beside the point that neither NPR's nor the above graph show mobility. I.e., the same person in 1970 and today is unlikely to belong to the same \"income class\"." ] } ], "metadata": {} } ] }