teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

Update

2021/12/05 08:39

投稿

melian
melian

スコア21265

answer CHANGED
@@ -9,12 +9,13 @@
9
9
  '''.strip()
10
10
 
11
11
  testList = np.loadtxt(io.StringIO(csv_data), delimiter=',', dtype='unicode')
12
+ testList = np.apply_along_axis(
12
- testList = np.apply_along_axis(lambda x: [x[0]]+list(x[1]), -1, testList)
13
+ lambda x: np.array([x[0]]+[*x[1]], dtype=object), -1, testList)
13
14
 
14
15
  print(testList)
15
16
 
16
17
  #
17
18
  [['cat' 'A' '1']
18
19
  ['dog' 'B' '1']
19
- ['woi' 'B' '2']]
20
+ ['woif' 'B' '2']]
20
21
  ```