11
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pythonのnumpy.zerosで”TypeError: data type not understood”が出るときの対処

Last updated at Posted at 2020-05-05
import numpy as np
n_mat = np.zeros(20, 20)

とすると,エラーがでる.

実行結果

      1 import numpy as n
----> 2 n_mat = np.zeros(20, 20)

TypeError: data type not understood

これは,次のようにすると回避できる.

import numpy as np
n_mat = np.zeros((20, 20))

つまり,zerosの引数はコンマ区切りではなく,タプル形式として入力する必要がある.
本当にしょうもない記事ではあるが,元MATLAB使いの私はこれで5分程度悩んだので,戒めとして記録しておく.

11
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?