前提・実現したいこと
Pythonを使用しています。
- 実現したい内容 …
「 tmpをflatten()を使って一次元配列にしたいです。」
実行したコードとその結果
実行したコード
このようなコードを実行しました。
python
1In[]: 2tmp = np.array([]) 3tmp_list = tmp.tolist() 4 5for i in range(2): 6 i += 1 7 tmp_list.append(np.array([(1375/(3**i))]*(3**i))) 8 9tmp = np.asarray(tmp_list) 10 11a = tmp.flatten() 12a
実行した結果
上記のコードを実行した結果、
以下のようになりました。
python
1Out[]: 2array([array([458.33333333, 458.33333333, 458.33333333]), 3 array([152.77777778, 152.77777778, 152.77777778, 152.77777778, 4 152.77777778, 152.77777778, 152.77777778, 152.77777778, 5 152.77777778])], dtype=object)
本来得たい結果
望んでいた実行結果は以下の通りです。
python
1Out[]: 2array([458.33333333, 458.33333333, 458.33333333, 152.77777778, 3152.77777778, 152.77777778, 152.77777778, 152.77777778, 152.77777778, 4152.77777778, 152.77777778, 152.77777778])
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。