How to operate NumPy

https://www.udemy.com/course/ds_for_python/ I'm going to forget the command while I'm doing

import


import numpy as np

flatten()

flatten


array1=np.array([[1,2,3],[4,5,6],[7,8,9]])
array1.flatten()

result

array([1, 2, 3, 4, 5, 6, 7, 8, 9])

squeeze

squeeze


array1=np.array([[1,2,3]])
array1.shape

(1, 3)

squeeze


np.squeeze(array1)

(3,)

Reduce dimensions.

expand_dims

expand_dims


ndarray1=np.array([1,2,3])
ndarray1.shape
expand_axis=np.expand_dims(ndarray1, axis=-1)
expand_axis.shape
expand_axis
(3,)

(3, 1)

array([[1],
       [2],
       [3]])

On the contrary, increase the dimension. The place to increase changes with the argument of ʻaxis`.

Recommended Posts

How to operate NumPy
How to use numpy
How to operate Linux from the console
How to install NumPy on Raspberry Pi
How to use xml.etree.ElementTree
How to use Python-shell
How to use tf.data
How to use virtualenv
Scraping 2 How to scrape
How to use Seaboan
How to use image-match
How to use shogun
How to install Python
How to read PyPI
How to install pip
How to use Virtualenv
How to use numpy.vectorize
How to update easy_install
How to install archlinux
How to speed up scikit-learn like conda Numpy
How to use pytest_report_header
How to install pip, numpy in Autodesk MAYA
How to restart gunicorn
How to virtual host
How to debug selenium
How to use partial
How to use Bio.Phylo
How to read JSON
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to update Spyder
How to install BayesOpt
How to operate Linux from the outside Procedure
[Pytorch] numpy to tensor
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use TokyoTechFes2015
How to use venv
How to use Pyenv
How to use list []
How to use python-kabusapi
How to install Nbextensions
How to use OptParse
How to use return
How to use dotenv
How to make Python faster for beginners [numpy]
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
How to write faster when using numpy like deque
How to operate Discord API with Python (bot registration)
How to operate Firefox with selenium on Windows Memo
How to estimate kernel density
How to use Qt Designer
[IPython] How to Share IPython Notebook
How to install Python [Windows]
How to use search sorted
Convert numpy int64 to python int