Skip to content

Instantly share code, notes, and snippets.

@maasg
Last active December 19, 2016 20:15
Show Gist options
  • Save maasg/d2d198efd70ae9226b7da916a8e709f4 to your computer and use it in GitHub Desktop.
Save maasg/d2d198efd70ae9226b7da916a8e709f4 to your computer and use it in GitHub Desktop.
Data Exploration.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "SO-records",
"user_save_timestamp": "1970-01-01T01:00:00.000Z",
"auto_save_timestamp": "1970-01-01T01:00:00.000Z",
"language_info": {
"name": "scala",
"file_extension": "scala",
"codemirror_mode": "text/x-scala"
},
"trusted": true,
"customLocalRepo": null,
"customRepos": null,
"customDeps": null,
"customImports": null,
"customArgs": null,
"customSparkConf": null
},
"cells": [
{
"metadata": {
"id": "687AC5EE2EA142D88E6112A74553191C"
},
"cell_type": "markdown",
"source": "created with the [Spark Notebook](http://http://spark-notebook.io/)"
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": false,
"id": "07DE8BF58435429A9171D0AC3690833C"
},
"cell_type": "code",
"source": "val sample1 = \"\"\"<row Id=\"42\" Reputation=\"11849\" CreationDate=\"2008-08-01T13:00:11.640\" DisplayName=\"Coincoin\" LastAccessDate=\"2014-01-18T20:32:32.443\" WebsiteUrl=\"\" Location=\"Montreal, Canada\" AboutMe=\"A guy with the attention span of a dead goldfish who has been having a blast in the industry for more than 10 years.&#xD;&#xA;&#xD;&#xA;Mostly specialized in game and graphics programming, from custom software 3D renderers to accelerated hardware pipeline programming.\" Views=\"648\" UpVotes=\"337\" DownVotes=\"40\" Age=\"35\" AccountId=\"33\" />\"\"\"\nval sample2 = \"\"\"<row Id=\"43\" Reputation=\"1149\" CreationDate=\"2008-08-01T13:00:11.640\" DisplayName=\"FooFoo\" LastAccessDate=\"2014-01-18T20:32:32.443\" WebsiteUrl=\"\" Location=\"Montreal, Canada\" AboutMe=\"foo\" Views=\"648\" UpVotes=\"337\" DownVotes=\"41\" Age=\"45\" AccountId=\"36\" />\"\"\"\nval sample3 = \"\"\"<row Id=\"44\" Reputation=\"345\" CreationDate=\"2008-08-01T13:00:11.640\" DisplayName=\"Baz\" LastAccessDate=\"2014-01-18T20:32:32.443\" WebsiteUrl=\"\" Location=\"NY, USA\" AboutMe=\"baz\" Views=\"65648\" UpVotes=\"337\" DownVotes=\"41\" Age=\"23\" AccountId=\"37\" />\"\"\"",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "sample1: String = <row Id=\"42\" Reputation=\"11849\" CreationDate=\"2008-08-01T13:00:11.640\" DisplayName=\"Coincoin\" LastAccessDate=\"2014-01-18T20:32:32.443\" WebsiteUrl=\"\" Location=\"Montreal, Canada\" AboutMe=\"A guy with the attention span of a dead goldfish who has been having a blast in the industry for more than 10 years.&#xD;&#xA;&#xD;&#xA;Mostly specialized in game and graphics programming, from custom software 3D renderers to accelerated hardware pipeline programming.\" Views=\"648\" UpVotes=\"337\" DownVotes=\"40\" Age=\"35\" AccountId=\"33\" />\nsample2: String = <row Id=\"43\" Reputation=\"1149\" CreationDate=\"2008-08-01T13:00:11.640\" DisplayName=\"FooFoo\" LastAccessDate=\"2014-01-18T20:32:32.443\" WebsiteUrl=\"\" Location=\"Montreal, Canada\" AboutMe=\"foo\" Views=\"648\" UpVotes=\"337\" DownVotes=\"41\" Age=\"45\"..."
},
{
"metadata": {},
"data": {
"text/html": ""
},
"output_type": "execute_result",
"execution_count": 18,
"time": "Took: 382 milliseconds, at 2016-12-19 21:10"
}
]
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": false,
"id": "DD673B985FE6409B82156CF2C5B09E78"
},
"cell_type": "code",
"source": "val lines = sparkContext.parallelize(Seq(sample1,sample2,sample3))",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "lines: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[20] at parallelize at <console>:83\n"
},
{
"metadata": {},
"data": {
"text/html": ""
},
"output_type": "execute_result",
"execution_count": 19,
"time": "Took: 364 milliseconds, at 2016-12-19 21:10"
}
]
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": false,
"id": "83125BE5857E4AAE907072007938951B"
},
"cell_type": "code",
"source": "val linesWithAge = lines.filter(line => line.contains(\"Age=\")) //transformations from the original input data\nval repSplit = linesWithAge.flatMap(line => line.split(\"\\\"\"))\nval withIndex = repSplit.zipWithIndex\nval indexKey = withIndex.map{case (k,v) => (v,k)}",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "linesWithAge: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[34] at filter at <console>:91\nrepSplit: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[35] at flatMap at <console>:92\nwithIndex: org.apache.spark.rdd.RDD[(String, Long)] = ZippedWithIndexRDD[36] at zipWithIndex at <console>:93\nindexKey: org.apache.spark.rdd.RDD[(Long, String)] = MapPartitionsRDD[37] at map at <console>:94\n"
},
{
"metadata": {},
"data": {
"text/html": ""
},
"output_type": "execute_result",
"execution_count": 26,
"time": "Took: 419 milliseconds, at 2016-12-19 21:12"
}
]
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": false,
"presentation": {
"tabs_state": "{\n \"tab_id\": \"#tab1932916894-0\"\n}",
"pivot_chart_state": "{\n \"hiddenAttributes\": [],\n \"menuLimit\": 200,\n \"cols\": [],\n \"rows\": [],\n \"vals\": [],\n \"exclusions\": {},\n \"inclusions\": {},\n \"unusedAttrsVertical\": 85,\n \"autoSortUnusedAttrs\": false,\n \"inclusionsInfo\": {},\n \"aggregatorName\": \"Count\",\n \"rendererName\": \"Table\"\n}"
},
"id": "559FAE88E30B41488109B19612C89D90"
},
"cell_type": "code",
"source": "indexKey.lookup(3)",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "res41: Seq[String] = WrappedArray(11849)\n"
},
{
"metadata": {},
"data": {
"text/html": "<div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anonb93227a6c1c037b7c8f7accde7b9f0f1&quot;,&quot;dataInit&quot;:[],&quot;genId&quot;:&quot;1932916894&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/tabs'], \n function(playground, _magictabs) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magictabs,\n \"o\": {}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <div>\n <ul class=\"nav nav-tabs\" id=\"ul1932916894\"><li>\n <a href=\"#tab1932916894-0\"><i class=\"fa fa-table\"/></a>\n </li><li>\n <a href=\"#tab1932916894-1\"><i class=\"fa fa-cubes\"/></a>\n </li></ul>\n\n <div class=\"tab-content\" id=\"tab1932916894\"><div class=\"tab-pane\" id=\"tab1932916894-0\">\n <div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anon0ae246f4c60fa45a1ca53b0728ea4efa&quot;,&quot;dataInit&quot;:[{&quot;string value&quot;:&quot;11849&quot;}],&quot;genId&quot;:&quot;762263571&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/tableChart'], \n function(playground, _magictableChart) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magictableChart,\n \"o\": {\"headers\":[\"string value\"],\"width\":600,\"height\":400}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <span class=\"chart-total-item-count\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anon09badc9d7674780575f6ee457230c944&quot;,&quot;initialValue&quot;:&quot;1&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p> entries total</span>\n <span class=\"chart-sampling-warning\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anon29124c8e5dfd05a9fb02676c89176821&quot;,&quot;initialValue&quot;:&quot;&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p></span>\n <div>\n </div>\n </div></div>\n </div><div class=\"tab-pane\" id=\"tab1932916894-1\">\n <div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anone93d8cfd53c0f107bc870b2d37d59455&quot;,&quot;dataInit&quot;:[{&quot;string value&quot;:&quot;11849&quot;}],&quot;genId&quot;:&quot;538385967&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/pivotChart'], \n function(playground, _magicpivotChart) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magicpivotChart,\n \"o\": {\"width\":600,\"height\":400,\"derivedAttributes\":{},\"extraOptions\":{}}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <span class=\"chart-total-item-count\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anon596203c0279d02e772dcf5a06b62f5c3&quot;,&quot;initialValue&quot;:&quot;1&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p> entries total</span>\n <span class=\"chart-sampling-warning\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anonfc611d5ef5ed4ee573ee2b625c62c2c3&quot;,&quot;initialValue&quot;:&quot;&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p></span>\n <div>\n </div>\n </div></div>\n </div></div>\n </div>\n </div></div>"
},
"output_type": "execute_result",
"execution_count": 27,
"time": "Took: 505 milliseconds, at 2016-12-19 21:12"
}
]
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": false,
"presentation": {
"tabs_state": "{\n \"tab_id\": \"#tab304851289-0\"\n}",
"pivot_chart_state": "{\n \"hiddenAttributes\": [],\n \"menuLimit\": 200,\n \"cols\": [],\n \"rows\": [],\n \"vals\": [],\n \"exclusions\": {},\n \"inclusions\": {},\n \"unusedAttrsVertical\": 85,\n \"autoSortUnusedAttrs\": false,\n \"inclusionsInfo\": {},\n \"aggregatorName\": \"Count\",\n \"rendererName\": \"Table\"\n}"
},
"id": "80BD73AF752D4F109A034DE712A3D84D"
},
"cell_type": "code",
"source": "indexKey.lookup(34)",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "res43: Seq[String] = WrappedArray(FooFoo)\n"
},
{
"metadata": {},
"data": {
"text/html": "<div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anon8e3924faf3d07f68e287e184f8a305f8&quot;,&quot;dataInit&quot;:[],&quot;genId&quot;:&quot;304851289&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/tabs'], \n function(playground, _magictabs) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magictabs,\n \"o\": {}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <div>\n <ul class=\"nav nav-tabs\" id=\"ul304851289\"><li>\n <a href=\"#tab304851289-0\"><i class=\"fa fa-table\"/></a>\n </li><li>\n <a href=\"#tab304851289-1\"><i class=\"fa fa-cubes\"/></a>\n </li></ul>\n\n <div class=\"tab-content\" id=\"tab304851289\"><div class=\"tab-pane\" id=\"tab304851289-0\">\n <div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anon9db5c4bc63d595a4b79704d5e0aaa1ec&quot;,&quot;dataInit&quot;:[{&quot;string value&quot;:&quot;FooFoo&quot;}],&quot;genId&quot;:&quot;100336524&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/tableChart'], \n function(playground, _magictableChart) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magictableChart,\n \"o\": {\"headers\":[\"string value\"],\"width\":600,\"height\":400}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <span class=\"chart-total-item-count\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anonfd3440575cb5d5bb176cb17f111faa8f&quot;,&quot;initialValue&quot;:&quot;1&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p> entries total</span>\n <span class=\"chart-sampling-warning\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anon4dba94853c33c7fd74598636abd19867&quot;,&quot;initialValue&quot;:&quot;&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p></span>\n <div>\n </div>\n </div></div>\n </div><div class=\"tab-pane\" id=\"tab304851289-1\">\n <div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anon1297185dfb0c086ef8c1d0a2f1cadf95&quot;,&quot;dataInit&quot;:[{&quot;string value&quot;:&quot;FooFoo&quot;}],&quot;genId&quot;:&quot;1746917619&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/pivotChart'], \n function(playground, _magicpivotChart) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magicpivotChart,\n \"o\": {\"width\":600,\"height\":400,\"derivedAttributes\":{},\"extraOptions\":{}}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <span class=\"chart-total-item-count\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anone3d8ca5aad13dd09e358691dd23fb9a8&quot;,&quot;initialValue&quot;:&quot;1&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p> entries total</span>\n <span class=\"chart-sampling-warning\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anond3351745e4672b0e25e90c39b8d6abd8&quot;,&quot;initialValue&quot;:&quot;&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p></span>\n <div>\n </div>\n </div></div>\n </div></div>\n </div>\n </div></div>"
},
"output_type": "execute_result",
"execution_count": 28,
"time": "Took: 433 milliseconds, at 2016-12-19 21:12"
}
]
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": false,
"presentation": {
"tabs_state": "{\n \"tab_id\": \"#tab31339161-0\"\n}",
"pivot_chart_state": "{\n \"hiddenAttributes\": [],\n \"menuLimit\": 200,\n \"cols\": [],\n \"rows\": [],\n \"vals\": [],\n \"exclusions\": {},\n \"inclusions\": {},\n \"unusedAttrsVertical\": 85,\n \"autoSortUnusedAttrs\": false,\n \"inclusionsInfo\": {},\n \"aggregatorName\": \"Count\",\n \"rendererName\": \"Table\"\n}"
},
"id": "175D3A60CC1B4263941F7A7CE2A9B010"
},
"cell_type": "code",
"source": "indexKey.lookup(61)",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "res45: Seq[String] = WrappedArray(Baz)\n"
},
{
"metadata": {},
"data": {
"text/html": "<div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anon208aae3947e6546b3f87614ce5cd77ac&quot;,&quot;dataInit&quot;:[],&quot;genId&quot;:&quot;31339161&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/tabs'], \n function(playground, _magictabs) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magictabs,\n \"o\": {}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <div>\n <ul class=\"nav nav-tabs\" id=\"ul31339161\"><li>\n <a href=\"#tab31339161-0\"><i class=\"fa fa-table\"/></a>\n </li><li>\n <a href=\"#tab31339161-1\"><i class=\"fa fa-cubes\"/></a>\n </li></ul>\n\n <div class=\"tab-content\" id=\"tab31339161\"><div class=\"tab-pane\" id=\"tab31339161-0\">\n <div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anonf1e5299c55ddaad293c35b4f18be2991&quot;,&quot;dataInit&quot;:[{&quot;string value&quot;:&quot;Baz&quot;}],&quot;genId&quot;:&quot;1054665930&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/tableChart'], \n function(playground, _magictableChart) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magictableChart,\n \"o\": {\"headers\":[\"string value\"],\"width\":600,\"height\":400}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <span class=\"chart-total-item-count\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anonbfcf5dd598508fd2c4278667c1eaf4dd&quot;,&quot;initialValue&quot;:&quot;1&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p> entries total</span>\n <span class=\"chart-sampling-warning\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anon62d595883c31880e3b98e3f326a68ef1&quot;,&quot;initialValue&quot;:&quot;&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p></span>\n <div>\n </div>\n </div></div>\n </div><div class=\"tab-pane\" id=\"tab31339161-1\">\n <div>\n <script data-this=\"{&quot;dataId&quot;:&quot;anone6f5345851f03ca057c8428865397d24&quot;,&quot;dataInit&quot;:[{&quot;string value&quot;:&quot;Baz&quot;}],&quot;genId&quot;:&quot;174546797&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/req(['../javascripts/notebook/playground','../javascripts/notebook/magic/pivotChart'], \n function(playground, _magicpivotChart) {\n // data ==> data-this (in observable.js's scopedEval) ==> this in JS => { dataId, dataInit, ... }\n // this ==> scope (in observable.js's scopedEval) ==> this.parentElement ==> div.container below (toHtml)\n\n playground.call(data,\n this\n ,\n {\n \"f\": _magicpivotChart,\n \"o\": {\"width\":600,\"height\":400,\"derivedAttributes\":{},\"extraOptions\":{}}\n }\n \n \n \n );\n }\n );/*]]>*/</script>\n <div>\n <span class=\"chart-total-item-count\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anonbaca11569c1260c4a6cce603164acd60&quot;,&quot;initialValue&quot;:&quot;1&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p> entries total</span>\n <span class=\"chart-sampling-warning\"><p data-bind=\"text: value\"><script data-this=\"{&quot;valueId&quot;:&quot;anon2e789bbb91c135706420ab501ae28390&quot;,&quot;initialValue&quot;:&quot;&quot;}\" type=\"text/x-scoped-javascript\">/*<![CDATA[*/\nreq(\n['observable', 'knockout'],\nfunction (O, ko) {\n ko.applyBindings({\n value: O.makeObservable(valueId, initialValue)\n },\n this\n );\n});\n /*]]>*/</script></p></span>\n <div>\n </div>\n </div></div>\n </div></div>\n </div>\n </div></div>"
},
"output_type": "execute_result",
"execution_count": 29,
"time": "Took: 523 milliseconds, at 2016-12-19 21:12"
}
]
},
{
"metadata": {
"id": "C6C0EDB3AA9C4125A79FC0416D10F30B"
},
"cell_type": "markdown",
"source": "## A better approach..."
},
{
"metadata": {
"trusted": true,
"input_collapsed": false,
"collapsed": true,
"id": "875550AB128246C9924F034799E803A4"
},
"cell_type": "code",
"source": "val reputationByAge = linesWithAge.map{line => \n val elements = line.split(\"\\\"\")\n val rep = line.???\n val age = line.???\n (rep, age)\n }",
"outputs": []
}
],
"nbformat": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment