A memo explaining the axis specification of axis

What are the row and column directions? I will leave a note before I forget it.

It will be simple if you catch it

a = np.array([
   [1, 1, 1],
   [1, 0, 1],
   [1, 0, 0],
   ])


print(np.all(a, axis=0)) #Row direction(From line 1 to line m)To see
print(np.all(a, axis=1)) #Column direction(From the 1st column to the nth column)
)To see

print(a)
a[2,0] = 0

print(np.all(a, axis=0))
print(np.all(a, axis=1))

>>> [ True False False]
>>> [ True False False]
>>> 
[[1 1 1]
 [1 0 1]
 [1 0 0]]
>>> [False False False] #From line 1 to line m
Look at True,False has been decided
>>> [ True False False] #From the 1st column to the nth column
Look at True,False has been decided

a = np.array([[1,2,3],
             [4,5,6]])
print(a)
np.sum(a, axis=0)
np.sum(a, axis=1)

>>> [[1 2 3]
 [4 5 6]]
>>> array([5, 7, 9]) #It is added along the 1st line to the mth line
>>> array([ 6, 15]) #It is added along the 1st to nth columns

Recommended Posts

A memo explaining the axis specification of axis
A memo to visually understand the axis of pandas.Panel
A memo about the behavior of bowtie2 during multiple hits
The story of writing a program
A memo that reproduces the slide show (gadget) of Windows 7 on Windows 10.
A rough understanding of python-fire and a memo
Measure the relevance strength of a crosstab
A quick overview of the Linux kernel
[python] [meta] Is the type of python a type?
Get the filename of a directory (glob)
The story of blackjack A processing (python)
Axis option specification summary of Python "numpy.sum (...)"
Notice the completion of a time-consuming command
A memo for utilizing the unit test mechanism KUnit of the Linux kernel
DJango Memo: From the beginning (preparation)
Illustration of the results of the knapsack problem
DJango Memo: From the beginning (model settings)
[Bash] Let's analyze the Fork bomb now
A memo explaining the axis specification of axis
How to calculate the volatility of a brand
A memo of a tutorial on running python on heroku
Machine learning memo of a fledgling engineer Part 1
Visualize the inner layer of a neural network
Make a copy of the list in Python
Follow the AR marker with a 2-axis servo
Find the number of days in a month
A note about the python version of python virtualenv
The story of making a lie news generator
Calculate the probability of outliers on a boxplot
Put the second axis in 2dhistgram of matplotlib
[Python] A rough understanding of the logging module
The story of making a mel icon generator
A discussion of the strengths and weaknesses of Python
Get the update date of the Python memo file.
A memo that implements the job of loading a GCS file into BigQuery in Python
A memo on how to overcome the difficult problem of capturing FX with AI
A memo of misunderstanding when trying to load the entire self-made module with Python3
The story of launching a Minecraft server from Discord
A story that reduces the effort of operation / maintenance
[Python] A program that counts the number of valleys
Get the variable name of the variable as a character string.
A memo connected to HiveServer2 of EMR with python
A memorandum about the warning of the pylint output result
Calculate volume from the two-dimensional structure of a compound
A memo of how to use AIST supercomputer ABCI
[GoLang] Set a space at the beginning of the comment
Cut a part of the string using a Python slice
Be careful when differentiating the eigenvectors of a matrix
Take a peek at the processing of LightGBM Tuner
Make a BOT that shortens the URL of Discord
Take a screenshot of the LCD with Python-LEGO Mindstorms
Make a note of the list of basic Pandas usage
A python implementation of the Bayesian linear regression class
Python points from the perspective of a C programmer
# Function that returns the character code of a string
The story of making a music generation neural network
A memo of installing Chainer 1.5 for GPU on Windows
The pain of gRPC using Python. November 2019. (Personal memo)
Visualize the characteristic vocabulary of a document with D3.js
Steps to calculate the likelihood of a normal distribution
Generate that shape of the bottom of a PET bottle
A memo that I touched the Datastore with python
A story about changing the master name of BlueZ
Tasks at the start of a new python project
Zip 4 Gbyte problem is a story of the past