[IPython-dev] Experiences getting a d3.js example working in the Notebook and request for advice
Mon Feb 10 15:37:54 CST 2014
Great stuff! I've been using pandas (http://pandas.pydata.org/) in the
notebook to create data for D3. I've used both df.to_csv() and
df.to_json() and methods to dump to CSV or serialize a dataframe to embed
embed D3 in the notebook itself. Very handy.
> Like many of you, I'm excited about the widgets and interact
> dev skills are modest (but which are rapidly growing while I'm learning
> about how to do more in the Notebook!), I have been focusing first on
> how to use the Notebook as a possible environment for the learning and
> as environments to try out and share small units of front end web
> programming and wonder how to use the Notebook in a similar fashion.
> As a short term challenge, I'm looking at learning/teaching d3.js using
> the Notebook -- and using d3.js specifically to plot US-related census
> data at the county level. I've wanted to rework Mike Bostock's
> Choropleth (http://bl.ocks.org/mbostock/4060606) example into IPython
> Notebook code that can take data calculated via Python and then
> displayed using d3.
> I *think* I just figured out how to make the Choropleth example show up
> in a Notebook:
> whose workings I illustrate in a silent video:
> I wrote up the mistakes I made to document the stumbling blocks for
> other novices to avoid. This example is not likely to be a big deal to
> experts -- but I'm interested in knowing whether I'm taking the right
> approach and how this example can be improved. Specifically:
> * Am I using requirejs correctly to load the external libraries in the
> * What will be the best way for me to dynamically construct data in
> Python to pass to d3? I'll want to replace the unemployment data (in
> unemployment.csv that d3 loads externally) to something I can pass to
> d3 from Python. Should I serialize the Python object into JSON, which I
> to serve up JSON data via a local URL (served up by the Notebook
> machinery)? If so, should I write the data out to a file that can be
> served up by the Notebook via http? Or is there a way to serve up data
> without explicitly writing to the local filesystem?
> * What gotchas should I be aware of, especially as someone who wants to
> show this in class tomorrow or later this week? :-)
> * Any tips on how I might think of turning my code into can be used with
> Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev