On Aug 30, 2011, at 10:46 AM, Marquette Jean-Baptiste wrote: > Hi all, > > I have this piece of code: > > Stats = [CatBase, round(stats.mean(Data.Ra), 5), round(stats.mean(Data.Dec), > 5), len(Sep), round(stats.mean(Sep),4), round(stats.stdev(Sep),4)] > print Stats > if First: > StatsAll = np.array(np.asarray(Stats), dtype=('a11, f8, f8, i4, f8, > f8')) > First = False > else: > StatsAll = np.vstack((StatsAll, np.asarray(Stats))) > print len(StatsAll) > > This yields the error: > > ['bs3000k.cat', 280.60341, -7.09118, 9480, 0.2057, 0.14] > Traceback (most recent call last): > File "/Users/marquett/workspace/Distort/src/StatsSep.py", line 40, in > <module> > StatsAll = np.array(np.asarray(Stats), dtype=('a11, f8, f8, i4, f8, f8')) > ValueError: could not convert string to float: bs3000k.cat > > What's wrong ?
My guess: Stats is a list of 5 elements, but you want a list of 1 5-element tuple to match the type. > Stats = [(CatBase, round(stats.mean(Data.Ra), 5), round(stats.mean(Data.Dec), > 5), len(Sep), round(stats.mean(Sep),4), round(stats.stdev(Sep),4),)] _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion