回答編集履歴
2
test
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
※ Pandas も使う場合。
|
2
|
-
|
3
2
|
```python
|
4
3
|
import numpy as np
|
5
4
|
import pandas as pd
|
@@ -11,14 +10,14 @@
|
|
11
10
|
[141, 5.669293427934539213e+05]])
|
12
11
|
|
13
12
|
df = pd.DataFrame(Dmrc)
|
14
|
-
df.insert(0, 'label', 'TBMAP2')
|
15
|
-
df.insert(1, 'idx', df.index+1000001)
|
16
13
|
df[0] = df[0].astype(int)
|
17
14
|
df[1] = df[1].map('{:.3e}'.format).replace(r'e([+-])0*', r'\1', regex=True)
|
18
|
-
df[2] =
|
15
|
+
df[2] = 'TBMAP2'
|
19
|
-
df[3] = df
|
16
|
+
df[3] = df.index + 1000001
|
20
17
|
df[4] = 1
|
18
|
+
df[5] = df[0] + 1000000
|
19
|
+
df[6] = 1
|
21
|
-
df = df[[
|
20
|
+
df = df[[2, 3, 1, 0, 4, 5, 6]]
|
22
21
|
|
23
22
|
np.savetxt("file.txt", df.values, fmt='%-8s%8d%8s%8d%8d%8d%8d')
|
24
23
|
```
|
1
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
df = pd.DataFrame(Dmrc)
|
14
14
|
df.insert(0, 'label', 'TBMAP2')
|
15
|
-
df.insert(1, 'idx', df.index+100000
|
15
|
+
df.insert(1, 'idx', df.index+1000001)
|
16
16
|
df[0] = df[0].astype(int)
|
17
|
-
df[1] = df[1].map('{:
|
17
|
+
df[1] = df[1].map('{:.3e}'.format).replace(r'e([+-])0*', r'\1', regex=True)
|
18
18
|
df[2] = 1
|
19
19
|
df[3] = df[0] + 1000000
|
20
20
|
df[4] = 1
|
@@ -25,9 +25,9 @@
|
|
25
25
|
|
26
26
|
**file.txt**
|
27
27
|
```fwf
|
28
|
-
TBMAP2 100000
|
28
|
+
TBMAP2 1000001 3.252+4 1 1 1000001 1
|
29
|
-
TBMAP2 100000
|
29
|
+
TBMAP2 1000002 8.318+5 36 1 1000036 1
|
30
|
-
TBMAP2 100000
|
30
|
+
TBMAP2 1000003 2.269+5 71 1 1000071 1
|
31
|
-
TBMAP2 100000
|
31
|
+
TBMAP2 1000004 1.146+5 106 1 1000106 1
|
32
|
-
TBMAP2 100000
|
32
|
+
TBMAP2 1000005 5.669+5 141 1 1000141 1
|
33
33
|
```
|