Skip to content

Instantly share code, notes, and snippets.

@davidthewatson
Created March 22, 2012 20:34
Show Gist options
  • Save davidthewatson/2163806 to your computer and use it in GitHub Desktop.
Save davidthewatson/2163806 to your computer and use it in GitHub Desktop.
d3py with numpy, pandas
import d3py
import numpy as np
import pandas
T = 10
df = pandas.DataFrame({
"time" : range(T),
"pressure": np.random.rand(T),
"temp" : np.random.rand(T)
})
print df
print 'df["pressure"] *= 100'
df['pressure'] *= 100
print df
df2 = pandas.DataFrame({'x': range(T)})
df3 = pow(df2['x'], 2)
print df3
#print df.to_csv('dog.csv')
## build up a figure, ggplot2 style
# instantiate the figure object
fig = d3py.Figure(df, name="index", width=800, height=600)
# add some red points
fig += d3py.geoms.Bar(x="time", y="temp",fill="red")
# writes 3 files, starts up a server, then draws some beautiful points in Chrome
#fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment