The following script draws the Normal Distribution of a sort of data given.
import numpy as np
import scipy.stats as stats
import pylab as pl
h = sorted ([0.9, 0.6, 0.5, 0.73788,...]) #Data that I would like to change
fit = stats.norm.pdf(h, np.mean(h), np.std(h))
pl.plot(h,fit,'-o')
pl.show()
I would like to find how to plot the data taken from a .csv file instead of having to introduce it manually. Suppose the data wanted is in the 2nd column of a given .csv file, the way I know to do something similar to isolate the data is by creating an intermediate file, but maybe this is not even necessary.
with open('infile.csv','rb') as inf, open('outfile.csv','wb') as outf:
incsv = csv.reader(inf, delimiter=',')
outcsv = csv.writer(outf, delimiter=',')
outcsv.writerows(row[1] in incsv)
Anyway, basically my two questions here are,
- Would I be writing correctly the second column of a .csv into a new .csv file?
- How could I merge those two scripts so that I can substitute the static data in the first one for the data in a column of a .csv file?