The %store magic allows data to be stored in the ipython database, outside of a notebook's particular kernel,
so it can be accessed from other notebooks.
If you're executing only one notebook, or this is the
| var xScale = d3.scaleTime() | |
| .domain(d3.extent(data, function(d) { return d.key; })) // Input | |
| .range([0, width]); // output | |
| // Quantize 400px - 1600px window range | |
| var tickScale = d3.scaleQuantize() | |
| .domain([400, 1600]) | |
| .range([3, 7, 10]); | |
| // Set number of ticks based on window height |
| // An array of discrete values (possibly dynamically generated) | |
| var discreteValues = ['John', 'Jack', 'Jill', 'Jane', 'Jim', 'Joan']; | |
| // 1st scale establishes relationship between continuous [0,1] and | |
| // the array index of the discrete values | |
| var preColor = d3.scaleLinear() | |
| .domain([0, discreteValues.length - 1]) | |
| .range([0, 1]); | |
| console.log(preColor(discreteValues.indexOf('John'))) // 0 | |
| console.log(preColor(discreteValues.indexOf('Jack'))) // 0.2 | |
| console.log(preColor(discreteValues.indexOf('Joan'))) // 1.0 |
| #!/bin/bash | |
| # Usage string | |
| usage() { | |
| cat << USAGE | |
| This script exists to serialize a local conda environment. | |
| The output files produced by this script are version-controllable, allowing | |
| for the local conda env definition to included with the repository, distributed, | |
| and recreated on other hosts using either conda *or* pip. |
| # You've got a Python dict in the driver program or shell | |
| x = {"a":1,"b":2} | |
| # You want to write it to a single HDFS file in JSON format | |
| sc.parallelize([x]).toDF().coalesce(1).write.mode('append').json(/hdfs/path/...) |
How to get almost equivalent Porter stemmers between Java and Python.
One remaining difference is how they handle non-dictionary words ending in "s":
Assuming you tokenize the following string after lowercase normalization using [a-z]\w+...
"EMI"s request for an appeal should be denied until a final judgment is entered. Document filed by Michael Robertson. (js) (Entered: 02/01/2012)"
| """ | |
| Remove *all* default, hard-coded, CSS classes and inline styling attached to tables when calling df.to_html(), | |
| and add your own classes to each tag ad hoc. | |
| This will probably be extremely simple in the future when the styling API is more mature. For now, we bleach it. | |
| May need to `conda install bleach` or `pip install bleach` | |
| """ | |
| import pandas as pd |
| from flask import Flask | |
| app = Flask(__name__) | |
| # Register core.utils with all template contexts | |
| import utils | |
| @app.context_processor | |
| def utils_context(): | |
| return utils.registry |