Standardized on df as the DataFrame variable for code snippets.

This commit is contained in:
Donne Martin 2015-01-31 08:00:08 -05:00
parent 45634da9ff
commit ebe737d11e

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:56fea349850ffa0f72e6b8900647ed0f5ede765deae5932b1a26237f03166107" "signature": "sha256:4c3e3bc5e2e66a53e95dce82d5f14b65d389cff01d434f1cf65ee91981716551"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -588,11 +588,11 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"data_1 = {'state': ['VA', 'VA', 'VA', 'MD', 'MD'],\n", "data_1 = {'state' : ['VA', 'VA', 'VA', 'MD', 'MD'],\n",
" 'year': [2012, 2013, 2014, 2014, 2015],\n", " 'year' : [2012, 2013, 2014, 2014, 2015],\n",
" 'pop': [5.0, 5.1, 5.2, 4.0, 4.1]}\n", " 'pop' : [5.0, 5.1, 5.2, 4.0, 4.1]}\n",
"frame_1 = DataFrame(data_1)\n", "df_1 = DataFrame(data_1)\n",
"frame_1" "df_1"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -670,8 +670,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_2 = DataFrame(data_1, columns=['year', 'state', 'pop'])\n", "df_2 = DataFrame(data_1, columns=['year', 'state', 'pop'])\n",
"frame_2" "df_2"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -749,8 +749,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3 = DataFrame(data_1, columns=['year', 'state', 'pop', 'unempl'])\n", "df_3 = DataFrame(data_1, columns=['year', 'state', 'pop', 'unempl'])\n",
"frame_3" "df_3"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -834,7 +834,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3['state']" "df_3['state']"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -866,7 +866,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.year" "df_3.year"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -898,7 +898,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.ix[0]" "df_3.ix[0]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -929,8 +929,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3['unempl'] = np.arange(5)\n", "df_3['unempl'] = np.arange(5)\n",
"frame_3" "df_3"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1015,8 +1015,8 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"unempl = Series([6.0, 6.0, 6.1], index=[2, 3, 4])\n", "unempl = Series([6.0, 6.0, 6.1], index=[2, 3, 4])\n",
"frame_3['unempl'] = unempl\n", "df_3['unempl'] = unempl\n",
"frame_3" "df_3"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1100,8 +1100,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3['state_dup'] = frame_3['state']\n", "df_3['state_dup'] = df_3['state']\n",
"frame_3" "df_3"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1191,8 +1191,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"del frame_3['state_dup']\n", "del df_3['state_dup']\n",
"frame_3" "df_3"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1278,8 +1278,8 @@
"input": [ "input": [
"pop = {'VA' : {2013 : 5.1, 2014 : 5.2},\n", "pop = {'VA' : {2013 : 5.1, 2014 : 5.2},\n",
" 'MD' : {2014 : 4.0, 2015 : 4.1}}\n", " 'MD' : {2014 : 4.0, 2015 : 4.1}}\n",
"frame_4 = DataFrame(pop)\n", "df_4 = DataFrame(pop)\n",
"frame_4" "df_4"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1339,7 +1339,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_4.T" "df_4.T"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1396,10 +1396,10 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"data_2 = {'VA' : frame_4['VA'][1:],\n", "data_2 = {'VA' : df_4['VA'][1:],\n",
" 'MD' : frame_4['MD'][2:]}\n", " 'MD' : df_4['MD'][2:]}\n",
"frame_5 = DataFrame(data_2)\n", "df_5 = DataFrame(data_2)\n",
"frame_5" "df_5"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1453,8 +1453,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_5.index.name = 'year'\n", "df_5.index.name = 'year'\n",
"frame_5" "df_5"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1514,8 +1514,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_5.columns.name = 'state'\n", "df_5.columns.name = 'state'\n",
"frame_5" "df_5"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1575,7 +1575,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_5.values" "df_5.values"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1603,7 +1603,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.values" "df_3.values"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1641,7 +1641,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3" "df_3"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1725,7 +1725,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.reindex(list(reversed(range(0, 6))))" "df_3.reindex(list(reversed(range(0, 6))))"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1817,7 +1817,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.reindex(range(6, 0), fill_value=0)" "df_3.reindex(range(6, 0), fill_value=0)"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -1931,7 +1931,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.reindex(columns=['state', 'pop', 'unempl', 'year'])" "df_3.reindex(columns=['state', 'pop', 'unempl', 'year'])"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2015,9 +2015,9 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_3.reindex(index=list(reversed(range(0, 6))),\n", "df_3.reindex(index=list(reversed(range(0, 6))),\n",
" fill_value=0,\n", " fill_value=0,\n",
" columns=['state', 'pop', 'unempl', 'year'])" " columns=['state', 'pop', 'unempl', 'year'])"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2109,8 +2109,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6 = frame_3.ix[range(0, 7), ['state', 'pop', 'unempl', 'year']]\n", "df_6 = df_3.ix[range(0, 7), ['state', 'pop', 'unempl', 'year']]\n",
"frame_6" "df_6"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2217,8 +2217,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_7 = frame_6.drop([0, 1])\n", "df_7 = df_6.drop([0, 1])\n",
"frame_7" "df_7"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2302,8 +2302,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_7 = frame_7.drop('unempl', axis=1)\n", "df_7 = df_7.drop('unempl', axis=1)\n",
"frame_7" "df_7"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2599,7 +2599,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6" "df_6"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2699,7 +2699,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6[['pop', 'unempl']]" "df_6[['pop', 'unempl']]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2783,7 +2783,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6[:2]" "df_6[:2]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2843,7 +2843,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6[frame_6['pop'] > 5]" "df_6[df_6['pop'] > 5]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -2903,7 +2903,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6 > 5" "df_6 > 5"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3003,7 +3003,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6[frame_6 > 5]" "df_6[df_6 > 5]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3103,7 +3103,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6.ix[2:3]" "df_6.ix[2:3]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3163,8 +3163,8 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6.ix[0:2, 'pop']\n", "df_6.ix[0:2, 'pop']\n",
"frame_6" "df_6"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3264,7 +3264,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_6.ix[frame_6.unempl > 5.0]" "df_6.ix[df_6.unempl > 5.0]"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3457,9 +3457,9 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"np.random.seed(0)\n", "np.random.seed(0)\n",
"frame_8 = DataFrame(np.random.rand(9).reshape((3, 3)),\n", "df_8 = DataFrame(np.random.rand(9).reshape((3, 3)),\n",
" columns=['a', 'b', 'c'])\n", " columns=['a', 'b', 'c'])\n",
"frame_8" "df_8"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3517,9 +3517,9 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"np.random.seed(1)\n", "np.random.seed(1)\n",
"frame_9 = DataFrame(np.random.rand(9).reshape((3, 3)),\n", "df_9 = DataFrame(np.random.rand(9).reshape((3, 3)),\n",
" columns=['b', 'c', 'd'])\n", " columns=['b', 'c', 'd'])\n",
"frame_9" "df_9"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3583,7 +3583,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_8 + frame_9" "df_8 + df_9"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -3651,7 +3651,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"frame_8.add(frame_9, fill_value=0)" "df_8.add(df_9, fill_value=0)"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},