What to do when "TypeError: data type not understood" appears in python's numpy.zeros

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

Then, an error occurs.


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

TypeError: data type not understood

This can be avoided by doing the following.

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

In other words, the zeros argument must be entered in tuple format, not comma separated. It's a really useless article, but as a former MATLAB user, I was worried about this for about 5 minutes, so I will record it as a commandment.

Recommended Posts

What to do when "TypeError: data type not understood" appears in python's numpy.zeros
[openpyxl] What to do when IllegalCharacterError appears in pandas.DataFrame.to_excel
What to do when "TypeError: must be string, not int…" appears when using strptime
What to do when "Invalid HTTP_HOST header" appears in Django
What to do when "Type Error: must be _socket.socket, not socket" appears on GAE
What to do when the value type is ambiguous in Python?
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
What to do when a warning appears around Python integration in Neovim's CheckHealth
What to do when [Errno 2] No such file or directory appears in Python
What to do when the graph does not appear in jupyter (ipython) notebook
What to do if NotADirectoryError: [Errno 20] Not a directory:'xdg-settings' appears in jupyter notebook
[Go 1.13] What to do when unexpected directory layout: appears
What to do when raise ValueError, "unsupported hash type"
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do when python3 type venv does not work well on Raspberry Pi
What to do when is not in the sudoers file.This incident will be reported.
What to do when Japanese is not displayed on matplotlib
TypeError: unsupported operand type (s) for-: What to do when'datetime.time'and'datetime.time'
OSError: [Errno 40] What to do when Message too long appears
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
What to do if Insecure Platform Warning appears when running Python
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
[virtualbox] What to do when [Could not retrieve mirrorlist] appears when yum update is performed on CentOS7
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
[Memorandum] What to do when a warning appears after executing pip list
A story about what to do when a bad interpreter: Not such file or directory appears in Anaconda3 and how to investigate the cause.
What to do when pyinstaller: error: argument --add-binary: invalid add_data_or_binary value: appears
[Docker] What to do when error Couldn't find the binary git appears
What to do if No Python documentation found for ... appears in pydoc
What to do if PyInstaller3.5 gives an error in Python3.8 (TypeError: an integer is required (got type bytes))
What to do in my case when pyenv install is not possible after upgrading to macOS Big Sur
What to do when "OS Error: [WinError 126] The specified module cannot be found" appears in import torch
Notes on what to do when matplotlib scatter () / scatter3d () does not work
After all, what should I use to do type comparisons in Python?
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do when a warning message is displayed in pip list
[Memorandum] What to do when a warning appears after executing pip list
What to do when a warning message is displayed in pip list
Example of what to do when the sample script does not work (OpenCV-Python)
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if abort is displayed when inputting camera video in OpenCV
[EC2] What to do when selenium is stuck and processing does not proceed
What to do when PermissionError of tempfile.mkstemp occurs
What to do to get google spreadsheet in python
[Python] What to do when No module named'pyproj.datadir' appears when Exe is done with PyInstaller
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do if Python does not switch from the System version in pyenv
What I do when imitating embedded go in python
What to do if pip install fails in Xcode 5.1
Forcible response when Warning appears in Python's requests library
curl: (60) What to do when Issuer certificate is invalid.
What to do when gdal_merge creates a huge file
What to do if a UnicodeDecodeError occurs in pip
What to do when "cannot import name xxx" [Python]
Do not pass self to ProcessPoolExecutor in the class
What to do if sys / cdefs.h does not exist
I want to do something in Python when I finish