回答編集履歴
1
追加
test
CHANGED
@@ -42,9 +42,19 @@
|
|
42
42
|
|
43
43
|
```python
|
44
44
|
|
45
|
+
# 方法1
|
46
|
+
|
45
47
|
out = np.full((len(arr), arr.max()+1), '', dtype='U1')
|
46
48
|
|
47
49
|
np.put_along_axis(out, arr, '1', 1)
|
50
|
+
|
51
|
+
pd.DataFrame(out[:, 1:]).to_csv('data2.csv', header=None, index=None)
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
# 方法2
|
56
|
+
|
57
|
+
out = np.where((arr==np.arange(arr.max()+1)[:, None, None]).any(2).T, '1', '')
|
48
58
|
|
49
59
|
pd.DataFrame(out[:, 1:]).to_csv('data2.csv', header=None, index=None)
|
50
60
|
|