python - Creating Pandas Dataframe between two Numpy arrays, then draw scatter plot -
i'm relatively new numpy , pandas (i'm experimental physicist i've been using root years...). common plot in root 2d scatter plot where, given list of x- , y- values, makes "heatmap" type scatter plot of 1 variable versus other.
how best accomplished numpy , pandas? i'm trying use dataframe.plot()
function, i'm struggling create dataframe.
import numpy np import pandas pd x = np.random.randn(1,5) y = np.sin(x) df = pd.dataframe(d)
first off, dataframe has shape (1,2), have shape (5,2). if can dataframe right shape, i'm sure can figure out dataframe.plot()
function draw want.
there number of ways create dataframes. given 1-dimensional column vectors, can create dataframe passing dict keys column names , values 1-dimensional column vectors:
import numpy np import pandas pd x = np.random.randn(5) y = np.sin(x) df = pd.dataframe({'x':x, 'y':y}) df.plot('x', 'y', kind='scatter')
Comments
Post a Comment