Created
March 22, 2012 20:34
-
-
Save davidthewatson/2163806 to your computer and use it in GitHub Desktop.
d3py with numpy, pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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