{ "metadata": { "language": "Julia", "name": "hacker_school_w_Stefan" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": "1+3", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 1, "text": "4" } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": "pwd()", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 2, "text": "\"/Users/polina\"" } ], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": "## FizzBuzz" }, { "cell_type": "code", "collapsed": false, "input": "function classify(i)\n if ((i%5 == 0) && (i%3 == 0))\n return \"fizzbuzz\"\n elseif i%3 == 0\n return \"fizz\"\n elseif i%5 == 0\n return \"buzz\"\n else\n return i\n end\nend", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 12, "text": "classify (generic function with 1 method)" } ], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": "for i = 1:100\n println(classify(i))\nend", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "1\n" }, { "output_type": "stream", "stream": "stdout", "text": "2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n11\nfizz\n13\n14\nfizzbuzz\n16\n17\nfizz\n19\nbuzz\nfizz\n22\n23\nfizz\nbuzz\n26\nfizz\n28\n29\nfizzbuzz\n31\n32\nfizz\n34\nbuzz\nfizz\n37\n38\nfizz\nbuzz\n41\nfizz\n43\n44\nfizzbuzz\n46\n47\nfizz\n49\nbuzz\nfizz\n52\n53\nfizz\nbuzz\n56\nfizz\n58\n59\nfizzbuzz\n61\n62\nfizz\n64\nbuzz\nfizz\n67\n68\nfizz\nbuzz\n71\nfizz\n73\n74\nfizzbuzz\n76\n77\nfizz\n79\nbuzz\nfizz\n82\n83\nfizz\nbuzz\n86\nfizz\n88\n89\nfizzbuzz\n91\n92\nfizz\n94\nbuzz\nfizz\n97\n98\nfizz\nbuzz\n" } ], "prompt_number": 13 }, { "cell_type": "markdown", "metadata": {}, "source": "## Array Comprehension" }, { "cell_type": "code", "collapsed": false, "input": "[ (x^2,y) for x in 1:10, y in primes(10) ]", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 15, "text": "10x4 Array{(Int64,Int64),2}:\n (1,2) (1,3) (1,5) (1,7) \n (4,2) (4,3) (4,5) (4,7) \n (9,2) (9,3) (9,5) (9,7) \n (16,2) (16,3) (16,5) (16,7) \n (25,2) (25,3) (25,5) (25,7) \n (36,2) (36,3) (36,5) (36,7) \n (49,2) (49,3) (49,5) (49,7) \n (64,2) (64,3) (64,5) (64,7) \n (81,2) (81,3) (81,5) (81,7) \n (100,2) (100,3) (100,5) (100,7)" } ], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": "hilbert(n) = [ 1/(i+j-1) for i=1:n, j=1:n ]", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 16, "text": "hilbert (generic function with 1 method)" } ], "prompt_number": 16 }, { "cell_type": "code", "collapsed": false, "input": "hilbert(10//1)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 18, "text": "10x10 Array{Rational{Int64},2}:\n 1//1 1//2 1//3 1//4 1//5 1//6 1//7 1//8 1//9 1//10\n 1//2 1//3 1//4 1//5 1//6 1//7 1//8 1//9 1//10 1//11\n 1//3 1//4 1//5 1//6 1//7 1//8 1//9 1//10 1//11 1//12\n 1//4 1//5 1//6 1//7 1//8 1//9 1//10 1//11 1//12 1//13\n 1//5 1//6 1//7 1//8 1//9 1//10 1//11 1//12 1//13 1//14\n 1//6 1//7 1//8 1//9 1//10 1//11 1//12 1//13 1//14 1//15\n 1//7 1//8 1//9 1//10 1//11 1//12 1//13 1//14 1//15 1//16\n 1//8 1//9 1//10 1//11 1//12 1//13 1//14 1//15 1//16 1//17\n 1//9 1//10 1//11 1//12 1//13 1//14 1//15 1//16 1//17 1//18\n 1//10 1//11 1//12 1//13 1//14 1//15 1//16 1//17 1//18 1//19" } ], "prompt_number": 18 }, { "cell_type": "code", "collapsed": false, "input": "hilbert(5)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 19, "text": "5x5 Array{Float64,2}:\n 1.0 0.5 0.333333 0.25 0.2 \n 0.5 0.333333 0.25 0.2 0.166667\n 0.333333 0.25 0.2 0.166667 0.142857\n 0.25 0.2 0.166667 0.142857 0.125 \n 0.2 0.166667 0.142857 0.125 0.111111" } ], "prompt_number": 19 }, { "cell_type": "markdown", "metadata": {}, "source": "## Boolean and Flow Control" }, { "cell_type": "code", "collapsed": false, "input": "true && false", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 21, "text": "false" } ], "prompt_number": 21 }, { "cell_type": "code", "collapsed": false, "input": "true & false", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 22, "text": "false" } ], "prompt_number": 22 }, { "cell_type": "code", "collapsed": false, "input": "7 & 9", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 23, "text": "1" } ], "prompt_number": 23 }, { "cell_type": "code", "collapsed": false, "input": "7 && 9", "language": "python", "metadata": {}, "outputs": [ { "ename": "LoadError", "evalue": "type: non-boolean (Int64) used in boolean context\nat In[24]:1", "output_type": "pyerr", "traceback": [ "type: non-boolean (Int64) used in boolean context\nat In[24]:1" ] } ], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": "p(v) = (println(v); v)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 25, "text": "p (generic function with 1 method)" } ], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": "function p(v)\n println(v)\n v\nend", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 26, "text": "p (generic function with 1 method)" } ], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": "p(true) & p(true)", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "true\n" }, { "output_type": "stream", "stream": "stdout", "text": "true\n" }, { "metadata": {}, "output_type": "pyout", "prompt_number": 27, "text": "true" } ], "prompt_number": 27 }, { "cell_type": "code", "collapsed": false, "input": "p(false) & p(true)", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "false\n" }, { "output_type": "stream", "stream": "stdout", "text": "true\n" }, { "metadata": {}, "output_type": "pyout", "prompt_number": 31, "text": "false" } ], "prompt_number": 31 }, { "cell_type": "code", "collapsed": false, "input": "p(false) && p(true) # short-circuit evaluation: will stop evaluating once it knows", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "false\n" }, { "metadata": {}, "output_type": "pyout", "prompt_number": 32, "text": "false" } ], "prompt_number": 32 }, { "cell_type": "code", "collapsed": false, "input": "p(true) ? p(\"hello\") : p(\"goodbye\")", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "true\n" }, { "output_type": "stream", "stream": "stdout", "text": "hello\n" }, { "metadata": {}, "output_type": "pyout", "prompt_number": 33, "text": "\"hello\"" } ], "prompt_number": 33 }, { "cell_type": "code", "collapsed": false, "input": "if p(false)\n p(\"hello\")\nelse\n p(\"goodbye\")\nend", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "false\n" }, { "output_type": "stream", "stream": "stdout", "text": "goodbye\n" }, { "metadata": {}, "output_type": "pyout", "prompt_number": 34, "text": "\"goodbye\"" } ], "prompt_number": 34 }, { "cell_type": "markdown", "metadata": {}, "source": "## FizzBuzz Part 2: Multiple Dispatch" }, { "cell_type": "code", "collapsed": false, "input": "type FizzBuzz{m,n} end", "language": "python", "metadata": {}, "outputs": [ { "ename": "LoadError", "evalue": "invalid redefinition of constant FizzBuzz\nat In[37]:1", "output_type": "pyerr", "traceback": [ "invalid redefinition of constant FizzBuzz\nat In[37]:1" ] } ], "prompt_number": 37 }, { "cell_type": "code", "collapsed": false, "input": "FizzBuzz{6,7}()", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 38, "text": "FizzBuzz{6,7}()" } ], "prompt_number": 38 }, { "cell_type": "code", "collapsed": false, "input": "typeof(ans)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 39, "text": "FizzBuzz{6,7} (constructor with 1 method)" } ], "prompt_number": 39 }, { "cell_type": "code", "collapsed": false, "input": "FizzBuzz(k) = FizzBuzz{k%3,k%5}()", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 40, "text": "FizzBuzz{m,n} (constructor with 1 method)" } ], "prompt_number": 40 }, { "cell_type": "code", "collapsed": false, "input": "[ typeof(FizzBuzz(k)) for k=1:10 ]", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 41, "text": "10-element Array{Type{_<:FizzBuzz{m,n}},1}:\n FizzBuzz{1,1}\n FizzBuzz{2,2}\n FizzBuzz{0,3}\n FizzBuzz{1,4}\n FizzBuzz{2,0}\n FizzBuzz{0,1}\n FizzBuzz{1,2}\n FizzBuzz{2,3}\n FizzBuzz{0,4}\n FizzBuzz{1,0}" } ], "prompt_number": 41 }, { "cell_type": "code", "collapsed": false, "input": "fizzit(k) = fizzit(FizzBuzz(k), k)\nfizzit(fb::FizzBuzz, k) = k\nfizzit(fb::FizzBuzz{0,0}, k) = \"FizzBuzz\"\nfizzit(fb::FizzBuzz{0}, k) = \"Fizz\"\nfizzit{m}(fb::FizzBuzz{m,0}, k) = \"Buzz\"", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 50, "text": "fizzit (generic function with 5 methods)" } ], "prompt_number": 50 }, { "cell_type": "code", "collapsed": false, "input": "for k = 1:20\n println(fizzit(k))\nend", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "1\n" }, { "output_type": "stream", "stream": "stdout", "text": "2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\n" } ], "prompt_number": 51 }, { "cell_type": "markdown", "metadata": {}, "source": "# FizzBuzz explicit vs implicit type parameters" }, { "cell_type": "code", "collapsed": false, "input": "type FizzBuzz2{m,n} end", "language": "python", "metadata": {}, "outputs": [ { "ename": "LoadError", "evalue": "invalid redefinition of constant FizzBuzz2\nat In[54]:1", "output_type": "pyerr", "traceback": [ "invalid redefinition of constant FizzBuzz2\nat In[54]:1" ] } ], "prompt_number": 54 }, { "cell_type": "code", "collapsed": false, "input": "fizzbuzz(k) = fizzbuzz(FizzBuzz2{k%3,k%5}(), k)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 55, "text": "fizzbuzz (generic function with 5 methods)" } ], "prompt_number": 55 }, { "cell_type": "markdown", "metadata": {}, "source": "# explicit type parameters:" }, { "cell_type": "code", "collapsed": false, "input": "fizzbuzz{m,n}(fb::FizzBuzz2{0,0}, k) = \"FizzBuzz\"\nfizzbuzz{m,n}(fb::FizzBuzz2{0,n}, k) = \"Fizz\"\nfizzbuzz{m,n}(fb::FizzBuzz2{m,0}, k) = \"Buzz\"\nfizzbuzz{m,n}(fb::FizzBuzz2{m,n}, k) = k", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 63, "text": "fizzbuzz (generic function with 8 methods)" }, { "output_type": "stream", "stream": "stderr", "text": "Warning: static parameter m does not occur in signature for fizzbuzz at In[63]:1.\nThe method will not be callable.\nWarning: static parameter n does not occur in signature for fizzbuzz at In[63]:1.\nThe method will not be callable.\nWarning: static parameter m does not occur in signature for fizzbuzz at In[63]:2.\nThe method will not be callable.\nWarning: static parameter n does not occur in signature for fizzbuzz at In[63]:3.\nThe method will not be callable.\n" } ], "prompt_number": 63 }, { "cell_type": "markdown", "metadata": {}, "source": "# implicit type parameters:" }, { "cell_type": "code", "collapsed": false, "input": "fizzbuzz(fb::FizzBuzz2{0,0}, k) = \"FizzBuzz\" \nfizzbuzz(fb::FizzBuzz2{0}, k) = \"Fizz\" \nfizzbuzz{m}(fb::FizzBuzz2{m,0}, k) = \"Buzz\" \nfizzbuzz(fb::FizzBuzz2, k) = k", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 59, "text": "fizzbuzz (generic function with 8 methods)" } ], "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": "for k = 1:100 println(fizzbuzz(k)) end", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "1\n" }, { "output_type": "stream", "stream": "stdout", "text": "2\nFizz\n4\n5\nFizz\n7\n8\nFizz\n10\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\n20\nFizz\n22\n23\nFizz\n25\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\n35\nFizz\n37\n38\nFizz\n40\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\n50\nFizz\n52\n53\nFizz\n55\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\n65\nFizz\n67\n68\nFizz\n70\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n79\n80\nFizz\n82\n83\nFizz\n85\n86\nFizz\n88\n89\nFizzBuzz\n91\n92\nFizz\n94\n95\nFizz\n97\n98\nFizz\n100\n" } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": "", "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": "## Example of Function Overloading" }, { "cell_type": "code", "collapsed": false, "input": "function foo(a::Real, b::Real)\n c = a + b \n # <= +(Real,Real) in static language, \n # in Julia dispatch will use JIT to call +(Int,Int) in the case they're Ints\n #...", "language": "python", "metadata": {}, "outputs": [ { "ename": "LoadError", "evalue": "syntax: incomplete: function at In[52]:1 requires end\nat In[52]:5", "output_type": "pyerr", "traceback": [ "syntax: incomplete: function at In[52]:1 requires end\nat In[52]:5" ] } ], "prompt_number": 52 }, { "cell_type": "markdown", "metadata": {}, "source": "## Data Analysis - NYC Housing data" }, { "cell_type": "code", "collapsed": false, "input": "using DataFrames", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": "Warning: New definition \n getindex(DataArray" }, { "output_type": "stream", "stream": "stderr", "text": "{T,N},Union(Ranges{T},Array{T,1})) at /Users/polina/.julia/DataFrames/src/dataarray.jl:356\nis ambiguous with \n getindex(DataArray{T<:Number,N},Union(BitArray{1},Ranges{T},Array{T,1})) at /Users/polina/.julia/DataFrames/src/dataarray.jl:340.\nMake sure \n getindex(DataArray{T<:Number,N},Union(Ranges{T},Array{T,1}))" }, { "output_type": "stream", "stream": "stderr", "text": "\nis defined first.\n" } ], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": "fb = DataArray([ FizzBuzz(k) for k=1:10])", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 57, "text": "10-element DataArray{FizzBuzz{m,n},1}:\n FizzBuzz{1,1}()\n FizzBuzz{2,2}()\n FizzBuzz{0,3}()\n FizzBuzz{1,4}()\n FizzBuzz{2,0}()\n FizzBuzz{0,1}()\n FizzBuzz{1,2}()\n FizzBuzz{2,3}()\n FizzBuzz{0,4}()\n FizzBuzz{1,0}()" } ], "prompt_number": 57 }, { "cell_type": "code", "collapsed": false, "input": "fb[3] = NA", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 59, "text": "NA" } ], "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": "fb", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 60, "text": "10-element DataArray{FizzBuzz{m,n},1}:\n FizzBuzz{1,1}()\n FizzBuzz{2,2}()\n NA \n FizzBuzz{1,4}()\n FizzBuzz{2,0}()\n FizzBuzz{0,1}()\n FizzBuzz{1,2}()\n FizzBuzz{2,3}()\n FizzBuzz{0,4}()\n FizzBuzz{1,0}()" } ], "prompt_number": 60 }, { "cell_type": "code", "collapsed": false, "input": "using Gadfly", "language": "python", "metadata": {}, "outputs": [ { "html": "", "metadata": {}, "output_type": "display_data" }, { "html": "", "metadata": {}, "output_type": "display_data" }, { "output_type": "stream", "stream": "stderr", "text": "Warning: Possible conflict in library symbol dtrtri_\nWarning: Possible conflict in library symbol dgetri_\nWarning: Possible conflict in library symbol dgetrf_\nWarning: using Base.Stat in module Stat conflicts with an existing identifier.\n" } ], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": "housing= readtable(\"Dev/Juliacode/housing.csv\")", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": "WARNING: max(x) is deprecated, use maximum(x) instead." }, { "metadata": {}, "output_type": "pyout", "prompt_number": 14, "text": "2626x13 DataFrame:\n Neighborhood Building.Classification Total.Units Year.Built Gross.SqFt Estimated.Gross.Income Gross.Income.per.SqFt Estimated.Expense Expense.per.SqFt Net.Operating.Income Full.Market.Value Market.Value.per.SqFt Boro\n[1,] \"FINANCIAL\" \"R9-CONDOMINIUM\" 42 1920 36500 1332615 36.51 342005 9.37 990610 7300000 200.0 \"Manhattan\"\n[2,] \"FINANCIAL\" \"R4-CONDOMINIUM\" 78 1985 126420 6633257 52.47 1762295 13.94 4870962 30690000 242.76 \"Manhattan\"\n[3,] \"FINANCIAL\" \"RR-CONDOMINIUM\" 500 NA 554174 17310000 31.24 3543000 6.39 13767000 90970000 164.15 \"Manhattan\"\n[4,] \"FINANCIAL\" \"R4-CONDOMINIUM\" 282 1930 249076 11776313 47.28 2784670 11.18 8991643 67556006 271.23 \"Manhattan\"\n[5,] \"TRIBECA\" \"R4-CONDOMINIUM\" 239 1985 219495 10004582 45.58 2783197 12.68 7221385 54320996 247.48 \"Manhattan\"\n[6,] \"TRIBECA\" \"R4-CONDOMINIUM\" 133 1986 139719 5127687 36.7 1497788 10.72 3629899 26737996 191.37 \"Manhattan\"\n[7,] \"TRIBECA\" \"R4-CONDOMINIUM\" 109 1985 105000 4365900 41.58 1273650 12.13 3092250 22210281 211.53 \"Manhattan\"\n[8,] \"TRIBECA\" \"R4-CONDOMINIUM\" 107 1986 87479 3637377 41.58 1061120 12.13 2576257 19449002 222.33 \"Manhattan\"\n[9,] \"TRIBECA\" \"R4-CONDOMINIUM\" 247 1987 255845 11246946 43.96 2440761 9.54 8806185 66316999 259.21 \"Manhattan\"\n[10,] \"TRIBECA\" \"R4-CONDOMINIUM\" 121 1985 106129 4115683 38.78 1231096 11.6 2884587 21821999 205.62 \"Manhattan\"\n[11,] \"TRIBECA\" \"R4-CONDOMINIUM\" 154 1986 126008 5239413 41.58 1528477 12.13 3710936 28015990 222.34 \"Manhattan\"\n[12,] \"TRIBECA\" \"R4-CONDOMINIUM\" 546 1987 586224 24375194 41.58 7110897 12.13 17264297 130154990 222.02 \"Manhattan\"\n[13,] \"TRIBECA\" \"R4-CONDOMINIUM\" 182 1988 208281 8077137 38.78 2416060 11.6 5661077 42824998 205.61 \"Manhattan\"\n[14,] \"TRIBECA\" \"R4-CONDOMINIUM\" 293 1988 341489 13591262 39.8 4309591 12.62 9281671 70161999 205.46 \"Manhattan\"\n[15,] \"TRIBECA\" \"R4-CONDOMINIUM\" 117 2003 267723 12202814 45.58 3394728 12.68 8808086 62110366 231.99 \"Manhattan\"\n[16,] \"TRIBECA\" \"R4-CONDOMINIUM\" 234 2006 431824 18041607 41.78 5298480 12.27 12743127 89682996 207.68 \"Manhattan\"\n[17,] \"TRIBECA\" \"R4-CONDOMINIUM\" 304 1985 257848 11752712 45.58 3269513 12.68 8483199 63811996 247.48 \"Manhattan\"\n[18,] \"TRIBECA\" \"R4-CONDOMINIUM\" 256 2006 434398 19799861 45.58 5508167 12.68 14291694 100582005 231.54 \"Manhattan\"\n[19,] \"TRIBECA\" \"R4-CONDOMINIUM\" 174 1985 237725 10051013 42.28 2498490 10.51 7552523 57048005 239.97 \"Manhattan\"\n[20,] \"FINANCIAL\" \"R4-CONDOMINIUM\" 13 1920 37236 1545666 41.51 439012 11.79 1106654 8355001 224.38 \"Manhattan\"\n :\n[2607,] \"SILVER LAKE\" \"R4-CONDOMINIUM\" 63 1931 64500 840435 13.03 437310 6.78 403125 2310006 35.81 \"Staten Island\"\n[2608,] \"SILVER LAKE\" \"R4-CONDOMINIUM\" 47 1937 51552 638729 12.39 339212 6.58 299517 1845800 35.8 \"Staten Island\"\n[2609,] \"TOMPKINSVILLE\" \"R4-CONDOMINIUM\" 147 1965 159096 1942562 12.21 905256 5.69 1037306 5697922 35.81 \"Staten Island\"\n[2610,] \"SUNNYSIDE\" \"R4-CONDOMINIUM\" 66 1981 65392 857943 13.12 430279 6.58 427664 2340743 35.8 \"Staten Island\"\n[2611,] \"GRYMES HILL\" \"R4-CONDOMINIUM\" 93 1987 72970 1162412 15.93 626812 8.59 535600 3654982 50.09 \"Staten Island\"\n[2612,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 243 1990 208726 2934688 14.06 1467344 7.03 1467344 9647986 46.22 \"Staten Island\"\n[2613,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 177 1983 195678 2334439 11.93 1299302 6.64 1035137 6602007 33.74 \"Staten Island\"\n[2614,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 31 1989 35212 495081 14.06 247540 7.03 247541 1443184 40.99 \"Staten Island\"\n[2615,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 31 1989 35212 470080 13.35 249236 7.08 220844 1443194 40.99 \"Staten Island\"\n[2616,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 31 1989 35212 470080 13.35 222540 6.32 247540 1443206 40.99 \"Staten Island\"\n[2617,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 31 1989 35212 470080 13.35 222540 6.32 247540 1443195 40.99 \"Staten Island\"\n[2618,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 37 1989 47880 673193 14.06 336596 7.03 336597 1931565 40.34 \"Staten Island\"\n[2619,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 52 1987 64512 861235 13.35 407716 6.32 453519 2308904 35.79 \"Staten Island\"\n[2620,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 37 1988 47880 673193 14.06 336596 7.03 336597 2115259 44.18 \"Staten Island\"\n[2621,] \"NEW SPRINGVILLE\" \"R4-CONDOMINIUM\" 37 NA 47880 673193 14.06 336596 7.03 336597 2115260 44.18 \"Staten Island\"\n[2622,] \"ROSEBANK\" \"R4-CONDOMINIUM\" 52 NA 62391 831672 13.33 326305 5.23 505367 3354003 53.76 \"Staten Island\"\n[2623,] \"ARROCHAR-SHORE ACRES\" \"R4-CONDOMINIUM\" 102 1987 90618 1274089 14.06 637045 7.03 637044 5233000 57.75 \"Staten Island\"\n[2624,] \"GRANT CITY\" \"R4-CONDOMINIUM\" 100 1986 78903 1321625 16.75 673832 8.54 647793 4687000 59.4 \"Staten Island\"\n[2625,] \"GRANT CITY\" \"R4-CONDOMINIUM\" 159 1961 166712 2343971 14.06 1171985 7.03 1171986 5967531 35.8 \"Staten Island\"\n[2626,] \"GREAT KILLS\" \"R4-CONDOMINIUM\" 67 1965 108864 1298748 11.93 722857 6.64 575891 3673011 33.74 \"Staten Island\"\n" }, { "output_type": "stream", "stream": "stderr", "text": "\n" } ], "prompt_number": 14 }, { "cell_type": "code", "collapsed": false, "input": "describe(housing)", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Neighborhood\n" }, { "output_type": "stream", "stream": "stdout", "text": "Length 2626" }, { "output_type": "stream", "stream": "stdout", "text": "\nType UTF8String\nNAs 0\nNA% 0.0%\nUnique 151" }, { "output_type": "stream", "stream": "stdout", "text": "\n\nBuilding.Classification\nLength 2626\nType UTF8String\nNAs 0\nNA% 0.0%\nUnique 4\n\nTotal.Units\nMin 1.0" }, { "output_type": "stream", "stream": "stdout", "text": "\n1st Qu. 15.0\nMedian 30.0\nMean 70.18392993145468\n3rd Qu. 75.0\nMax 3378.0\nNAs 0\nNA% 0.0%\n\nYear.Built\nMin 1825.0\n1st Qu. 1926.0\nMedian 1986.0\nMean 1967.4604743083005\n3rd Qu. 2005.0\nMax 2010.0\nNAs 96\nNA% 3.66%\n\nGross.SqFt\nMin 478.0\n1st Qu. 18704.5\nMedian 38455.5\nMean 82762.86557501904\n3rd Qu. 90626.25\nMax 3.364977e6\nNAs 0\nNA% 0.0%\n\nEstimated.Gross.Income\nMin 6424.0\n1st Qu. 405180.0\nMedian 943901.0\nMean 2.640881935262757e6\n3rd Qu. 2.7255505e6\nMax 5.6010967e7\nNAs 0\nNA% 0.0%\n\nGross.Income.per.SqFt\nMin 3.57" }, { "output_type": "stream", "stream": "stdout", "text": "\n1st Qu. 18.79\nMedian 25.0\nMean 27.572136329017404\n3rd Qu. 36.82\nMax 62.8\nNAs 0\nNA% 0.0%\n\nEstimated.Expense\nMin 1740.0\n1st Qu. 155514.75\nMedian 350263.5\nMean 840916.0811119573\n3rd Qu. 899084.5\nMax 2.1771401e7\nNAs 0\nNA% 0.0%\n\nExpense.per.SqFt\nMin 0.97\n1st Qu. 7.64\nMedian 9.18\nMean 9.400316070068552\n3rd Qu. 11.05\nMax 18.21\nNAs 0\nNA% 0.0%\n\nNet.Operating.Income\nMin 4684.0\n1st Qu. 239699.75\nMedian 581522.5\nMean 1.7999658541507998e6\n3rd Qu. 1.80514925e6\nMax 4.0144686e7\nNAs 0\nNA% 0.0%\n\nFull.Market.Value\nMin 30000.0\n1st Qu. 1.67775025e6\nMedian 4.0264995e6\nMean 1.2977807587966489e7\n3rd Qu. 1.31367525e7\nMax 2.95182007e8\nNAs 0\nNA% 0.0%\n\nMarket.Value.per.SqFt\nMin 10.66\n1st Qu. 74.6325\nMedian 112.22\nMean 131.18720487433353\n3rd Qu. 187.49\nMax 399.38\nNAs 0\nNA% 0.0%\n\nBoro\nLength 2626\nType UTF8String\nNAs 0\nNA% 0.0%\nUnique 5\n\n" } ], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": "plot(housing, x=\"Gross.SqFt\", y=\"Estimated.Expense\", Geom.point, Scale.x_log10, Scale.y_log10, color=\"Boro\")", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": "WARNING: min(x) is deprecated, use minimum(x) instead." }, { "html": "
\n\n", "metadata": {}, "output_type": "display_data", "text": "D3(120.0,80.0,IOBuffer([0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x20,0x64 \u2026 0x74,0x5f,0x69,0x64,0x29,0x3b,0x0a,0x7d,0x3b,0x0a],true,true,true,false,240571,9223372036854775807,240572),false,0,[],[],1,5,[0x4675f1a7f9dacb5e=>([32.865679413460725,25.280856777935412,22.050139027963482,23.16432642487141,23.166774166061053,26.033199641587853,26.78311365069196,27.627675774150603,23.77414584577887,26.94031999878623 \u2026 34.85363026600855,32.939429625899606,32.05265085342272,32.939429625899606,32.939429625899606,33.08307623807305,29.98813250489511,29.728416887640616,27.167955033108754,29.403518214873163],1),0x45b0c342ef642998=>({LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0) \u2026 LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435)},3),0xb2502fb0cf4c1a5e=>([LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0) \u2026 LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435)],4),0x985158a218b0a4c1=>([56.007439317532935,63.188145463490464,71.73049839932787,67.10796695892353,66.3771864513453,63.766299947164605,62.11505832102227,61.05981900292189,67.26295516843452,62.17687728921297 \u2026 55.799784364104816,57.57609778288877,59.2994787464346,57.57609778288877,57.57609778288877,59.10624597416203,61.263594166303164,60.463422557916,64.78727968560757,62.323948612934984],0),0x09484aecf69294c5=>([\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\" \u2026 \"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\"],2)],true,true)" }, { "html": "", "metadata": {}, "output_type": "pyout", "prompt_number": 16, "text": "Plot(...)" }, { "output_type": "stream", "stream": "stderr", "text": "\n" } ], "prompt_number": 16 }, { "cell_type": "code", "collapsed": false, "input": "plot(housing, y=\"Expense.per.SqFt\", x=\"Gross.SqFt\", Geom.point, Scale.x_log10, Scale.y_log10, color=\"Boro\")", "language": "python", "metadata": {}, "outputs": [ { "html": "
\n\n", "metadata": {}, "output_type": "display_data", "text": "D3(120.0,80.0,IOBuffer([0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x20,0x64 \u2026 0x74,0x5f,0x69,0x64,0x29,0x3b,0x0a,0x7d,0x3b,0x0a],true,true,true,false,239955,9223372036854775807,239956),false,0,[],[],1,5,[0xbd853645b094f584=>([56.749057922071,63.77514060593368,72.13354948967827,67.61055586636729,66.89551138945463,64.34084558310049,62.725160445665466,61.69264378929038,67.76220668634426,62.78564825467899 \u2026 56.54587444083066,58.28393817706319,59.97020926232194,58.28393817706319,58.28393817706319,59.78113740676586,61.892031024714356,61.10908965829002,65.33984037762878,62.92955266462031],0),0xec4d828a42a9df50=>([\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\" \u2026 \"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\"],2),0x5a49b4c91ea24740=>({LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0) \u2026 LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435)},3),0x40c9654fb83bb1b6=>([20.665595704198225,16.071238527267628,25.092595612702855,18.622986963957626,17.1669059282549,19.10891191386257,17.679765758504494,17.679765758504494,20.457644857408248,18.196469922108264 \u2026 25.219989468068082,23.988647585732608,25.219989468068082,23.988647585732608,23.988647585732608,27.40941617652883,23.988647585732608,21.73831304694096,23.988647585732608,24.648741250012787],1),0xadae336ea3f8d222=>([LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0) \u2026 LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435)],4)],true,true)" }, { "html": "", "metadata": {}, "output_type": "pyout", "prompt_number": 24, "text": "Plot(...)" } ], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": "colnames(housing)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 22, "text": "13-element Array{Union(ASCIIString,UTF8String),1}:\n \"Neighborhood\" \n \"Building.Classification\"\n \"Total.Units\" \n \"Year.Built\" \n \"Gross.SqFt\" \n \"Estimated.Gross.Income\" \n \"Gross.Income.per.SqFt\" \n \"Estimated.Expense\" \n \"Expense.per.SqFt\" \n \"Net.Operating.Income\" \n \"Full.Market.Value\" \n \"Market.Value.per.SqFt\" \n \"Boro\" " } ], "prompt_number": 22 }, { "cell_type": "code", "collapsed": false, "input": "plot(housing, x=\"Total.Units\", y=\"Full.Market.Value\", Geom.point, Scale.x_log10, Scale.y_log10, color=\"Boro\")", "language": "python", "metadata": {}, "outputs": [ { "html": "
\n\n", "metadata": {}, "output_type": "display_data", "text": "D3(120.0,80.0,IOBuffer([0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x20,0x64 \u2026 0x74,0x5f,0x69,0x64,0x29,0x3b,0x0a,0x7d,0x3b,0x0a],true,true,true,false,239368,9223372036854775807,239369),false,0,[],[],1,5,[0xb6e3fdeea8c2e2ca=>({LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0),LCHab(50.0,70.0,0.0) \u2026 LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435),LCHab(65.0,70.0,315.6521739130435)},3),0xeaba19680b66c998=>([LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0),LCHab(65.0,70.0,0.0) \u2026 LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435),LCHab(80.0,70.0,315.6521739130435)],4),0xcfae6309da57aea4=>([\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\",\"geometry color_Manhattan\" \u2026 \"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\",\"geometry color_Staten_Island\"],2),0x4708ccfbf0e47c42=>([29.35802853599928,22.7145590606495,17.687795428804442,19.06441785865873,20.073136451577156,23.352282360579295,24.210577247409823,24.824745423537866,19.150051564824132,24.292167623129295 \u2026 36.857119372976214,35.508724260559966,34.68321937709641,35.0884519353298,35.088449748283665,32.95589256598029,30.898032541864694,31.40779951518452,30.29039182445748,32.535571687544845],1),0x61acae2da84c2561=>([48.91047128942169,53.38317094043411,66.80691746803949,62.669021756461916,61.47365454922436,57.23884398669259,55.80101453838712,55.66721018906511,61.71154363770501,56.55563663283854 \u2026 46.716296497632754,47.99466126983179,50.45359293809369,47.99466126983179,47.99466126983179,50.45359293809369,55.32143950715445,55.17836100260417,58.52894517303848,52.28481912668823],0)],true,true)" }, { "html": "", "metadata": {}, "output_type": "pyout", "prompt_number": 27, "text": "Plot(...)" } ], "prompt_number": 27 }, { "cell_type": "code", "collapsed": false, "input": "plot(housing, x=\"Total.Units\", y=\"Full.Market.Value\", Geom.RectangularBinGeometry, Scale.x_log10, Scale.y_log10,color=\"Boro\")", "language": "python", "metadata": {}, "outputs": [ { "html": "
\n\n", "metadata": {}, "output_type": "display_data", "text": "D3(120.0,80.0,IOBuffer([0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x20,0x64 \u2026 0x74,0x5f,0x69,0x64,0x29,0x3b,0x0a,0x7d,0x3b,0x0a],true,true,true,false,613123,9223372036854775807,613124),false,0,[],[],0,5,Dict{Uint64,(Any,Int64)}(),true,true)" }, { "html": "", "metadata": {}, "output_type": "pyout", "prompt_number": 41, "text": "Plot(...)" } ], "prompt_number": 41 }, { "cell_type": "code", "collapsed": false, "input": "", "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }