From: Lionel R. <lro...@li...> - 2006-09-18 07:39:18
|
Le vendredi 15 septembre 2006 16:05, Francesc Altet a =E9crit=A0: > Another possibility is to play with columns directly from the initial > recarray. The next is an example: > > In [101]: ra=3Dnumpy.rec.array("1"*36, dtype=3D"a4,i4,f4", shape=3D3) > In [102]: ra > Out[102]: > recarray([('1111', 825307441, 2.5784852031307537e-09), > ('1111', 825307441, 2.5784852031307537e-09), > ('1111', 825307441, 2.5784852031307537e-09)], > dtype=3D[('f0', '|S4'), ('f1', '<i4'), ('f2', '<f4')]) > In [103]: rb=3Dnumpy.rec.fromarrays([numpy.array(ra['f0'], 'i4'),ra['f2']= ], > names=3D'f0,f1') > In [104]: rb > Out[104]: > recarray([(1111, 2.5784852031307537e-09), (1111, 2.5784852031307537e-09), > (1111, 2.5784852031307537e-09)], > dtype=3D[('f0', '<i4'), ('f1', '<f4')]) > > where ra is the original recarray and rb is a derived one where its first > column is the original from ra, but converted to integers ('i4'), and the > second it's the third column from ra (so the second column from ra has be= en > stripped out from rb). I have a problem with that : lionel[ETD-2006-01__PM2.5_DALTON]334>datas[0:5] Sortie[334]: [['Dates ', 'PM10 ', 'c10', 'PM2.5 ', 'c2.5'], ['05/01/2006', '33', 'A', '', 'N'], ['06/01/2006', '41', 'A', '30', 'A'], ['07/01/2006', '20', 'A', '16', 'A'], ['08/01/2006', '16', 'A', '13', 'A']] lionel[ETD-2006-01__PM2.5_DALTON] 335>ra=3Drec.array(datas[1:],formats=3D'a10,i2,a1,i2,a1') lionel[ETD-2006-01__PM2.5_DALTON]336>ra[0:5] Sortie[336]: recarray([[('05/01/2006', 0, '', 0, ''), ('33', 0, '', 0, ''), ('A[9\xb4q\x00\x00\x00\xc0\xa3', -18448, '\xc0', -3933, '\xb7'), ('30', 0, '', 0, ''), ('N\x00\x00\x00\x00\x00\x00\x00t\xeb', -18496, '\x19', 13, '')], [('06/01/2006', 0, '', 0, ''), ('41', 0, '', 0, ''), ('A[9\xb4q\x00\x00\x00\xc0\xa3', -18448, '\xc0', -3933, '\xb7'), ('30', 0, '', 0, ''), ('A\x00\x00\x00\x00\x00\x00\x00t\xeb', -18496, '\x19', 13, '')], [('07/01/2006', 0, '', 0, ''), ('20', 0, '', 0, ''), ('A[9\xb4q\x00\x00\x00\xc0\xa3', -18448, '\xc0', -3933, '\xb7'), ('16', 0, '', 0, ''), ('A\x00\x00\x00\x00\x00\x00\x00t\xeb', -18496, '\x19', 13, '')], [('08/01/2006', 0, '', 0, ''), ('16', 0, '', 0, ''), ('A[9\xb4q\x00\x00\x00\xc0\xa3', -18448, '\xc0', -3933, '\xb7'), ('13', 0, '', 0, ''), ('A\x00\x00\x00\x00\x00\x00\x00t\xeb', -18496, '\x19', 13, '')], [('09/01/2006', 0, '', 0, ''), ('18', 0, '', 0, ''), ('A[9\xb4q\x00\x00\x00\xc0\xa3', -18448, '\xc0', -3933, '\xb7'), ('15', 0, '', 0, ''), ('A\x00\x00\x00\x00\x00\x00\x00t\xeb', -18496, '\x19', 13, '')]], dtype=3D[('f1', '|S10'), ('f2', '<i2'), ('f3', '|S1'), ('f4', '<i2'),= =20 ('f5', '|S1')]) I have some missing entries, is it for that or do I have to make some chang= es=20 on the date column? thanks =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |