回答編集履歴
1
追加
answer
CHANGED
@@ -20,9 +20,14 @@
|
|
20
20
|
このとき、
|
21
21
|
|
22
22
|
```python
|
23
|
+
# 方法1
|
23
24
|
out = np.full((len(arr), arr.max()+1), '', dtype='U1')
|
24
25
|
np.put_along_axis(out, arr, '1', 1)
|
25
26
|
pd.DataFrame(out[:, 1:]).to_csv('data2.csv', header=None, index=None)
|
27
|
+
|
28
|
+
# 方法2
|
29
|
+
out = np.where((arr==np.arange(arr.max()+1)[:, None, None]).any(2).T, '1', '')
|
30
|
+
pd.DataFrame(out[:, 1:]).to_csv('data2.csv', header=None, index=None)
|
26
31
|
```
|
27
32
|
|
28
33
|
```
|