noob, Python NumPy . NumPy ( Pandas), . ,
( , ):
1 66.295962
2 66.318076
3 66.479436
4 66.460284
5 66.551778
6 66.303606
7 66.222943
8 66.50905
9 66.268011
10 66.291807
,
>>> import numpy as np
>>> import numpy.lib.recfunctions as rfn
(dtype).
>>> f = np.loadtxt("f:/test/test.txt",dtype=[('ID','int32'),('Value','float64')])
>>> f
array([(1, 66.295962), (2, 66.318076), (3, 66.479436), (4, 66.460284),
(5, 66.551778), (6, 66.303606), (7, 66.222943), (8, 66.50905),
(9, 66.268011), (10, 66.291807)],
dtype=[('ID', '<i4'), ('Value', '<f8')])
, / ,
>>> a = f['Value']
>>> a1 = np.roll(a,-1)
>>> diff = a1-a
,
( mumbo-jumbo, , )
>>> out = rfn.merge_arrays((f, diff), asrecarray=True, flatten=True)
, ,
.
>>> np.savetxt("f:/test/out.txt", out, delimiter="",fmt='% 10i % 10.6f % 10.6f')
( ..).
1 66.295962 0.022114
2 66.318076 0.161360
3 66.479436 -0.019152
4 66.460284 0.091494
5 66.551778 -0.248172
6 66.303606 -0.080663
7 66.222943 0.286107
8 66.509050 -0.241039
9 66.268011 0.023796
10 66.291807 0.004155
... - . , , , . , 2. , / 0, , .