[PYTHON] About axis = 0, axis = 1

This time I will talk about axis in Python (numpy and pandas).

■ Basic rules of axis

axis = 0: Row direction (direction from row 01 to 02) → Vertical direction axis = 1: Column direction (direction from column A to B) → horizontal direction image.png

■ Actually check

Let's prepare two DataFrames in pandas. image.png Now concat (concatenate data frames). image.png From the above, we were able to confirm the function of axis.

References: A new data analysis textbook in Python (Official text of Python 3 engineer certification data analysis test) URL:https://cbt.odyssey-com.co.jp/pythonic-exam.html

■ There are exceptions

Regarding axis, from basic operation of numpy to data frame concatenation of pandas It can be processed based on the above basic rules.

However, some of them are as follows. image.png Thinking normally

If it is line (02), it will be deleted horizontally, so axis = 1 If it is column (B), it will be deleted vertically, so axis = 0

It may become.

In this case, it's just a nuance,

-Move in the row direction (vertical) and select the row you want to delete → axis = 0 -Move to the column direction (horizontal) and select the column you want to delete → axis = 1

It is good to think that.

Recommended Posts

About axis = 0, axis = 1
About LangID
About CAGR
About virtiofs
About python-apt
About sklearn.preprocessing.Imputer
About gunicorn
About requirements.txt
About permissions
About Opencv ②
About Opencv ③
About import
About numpy
About pip
About Linux
About numpy.newaxis
NumPy axis
About endian
About Linux
About import
About Opencv ①
About Linux
About Linux
About Linux ①
About cv2.imread
About _ and __
About wxPython
Notepad about TecoGAN
About python slices
Briefly about __name__
About python comprehension
About Docker Volume
[Linux] About export
About reference type
About Twitter scraping
About the test
Learn about programming
About variable scope. .. ..
About Python tqdm.
About python yield
About python, class
About Linear Models
About Go functions
About pandas describe
About Kivy root
About Firestore timeout
About python inheritance
About python, range ()
Understand numpy's axis
About Confusion Matrix
[Linux] About PATH
About python decorators
Linux (about groups)
Note about awk
About python reference
About Bitnami Autostart
About Python decorators
About Milkcocoa SDK
Notes about pytorch
[Python] About multi-process
About Numpy broadcast