[PYTHON] For the first time in Numpy, I will update it from time to time

1. Started Numpy

When I start studying Numpy and find out how to specify arguments and usage examples, I will forget it. I will update it from time to time and use it as a memo pad. Please note that the order and comprehensibility are secondary, so it may be difficult to understand. After a quick look, Numpy is a library that specializes in numerical calculations, so It seems that there are many functions for calculation

2. I'm impressed with this

Suguremono that uses the four arithmetic operations of python +,-, *, / to perform four arithmetic operations on each element of the array. It calculates without taking out the elements one by one. Recently, I've been touching pandas for a long time, so I didn't notice it, but my senior advised me to use numpy so much that I could remember it, so I think I'll try to remember it while playing around.

3. Do you want to do it

<np.array(object, dtype=None)>

array.py


#np.array()Generate ndarray with
A = np.array([1,3,5,7,9])
#--->array([1, 3, 5, 7, 9])
A -= 4 
#---> array([-3, -1,  1,  3,  5])
#4 is subtracted for each element.

It's amazing that each element is subtracted This seems to have something to do with broadcast (more on that later) It seems that object will contain the type array_like. The array_like is an array represented by multiple lists and tuples in addition to ndarray. This ndarray is a class for n to handle __n-dimensional __arrays Since ndarray must basically consist of all elements of the same type, Pandas is easier to handle when working with arrays containing multiple data types (numeric types, strings, etc.)

<np.dot>

np.dot


a = np.array([1,2,3])
b = np.array([3,4,5])
#---> 26
Product of one-dimensional arrays
a = np.array([[1,2],
              [4,5],
              [1,2]])
b = np.array([[4,6,7],
              [6,5,3]])
x = np.dot(a,b)
---------------------
#result
array([[16, 16, 13],
       [46, 49, 43],
       [16, 16, 13]])
x.dtype: int64
x.ndim:Number of dimensions:2
x.shape: (line,Column):(3, 3)

<np.maximum>

<np.max> <np.exp>

Recommended Posts

For the first time in Numpy, I will update it from time to time
AI Gaming I tried it for the first time
I tried tensorflow for the first time
MongoDB for the first time in Python
I tried using scrapy for the first time
I tried python programming for the first time.
I tried Mind Meld for the first time
Try posting to Qiita for the first time
GTUG Girls + PyLadiesTokyo Meetup I went to machine learning for the first time
What I got into Python for the first time
I tried Python on Mac for the first time.
Register a task in cron for the first time
For the first time, I learned about Unix (Linux).
I will install Arch Linux for the time being.
I read the Chainer reference (updated from time to time)
Kaggle for the first time (kaggle ①)
Kaguru for the first time
I thought it would be slow to use a for statement in NumPy, but that wasn't the case.
I will try to summarize the links that seem to be useful for the time being
After attending school, I participated in SIGNATE's BEGINNER limited competition for the first time.
I want to create a lunch database [EP1] Django study for the first time
I want to create a lunch database [EP1-4] Django study for the first time
I want to move selenium for the time being [for mac]
Summary of stumbling blocks in Django for the first time
I tried to illustrate the time and time in C language
I wrote it in Go to understand the SOLID principle
I tried the Google Cloud Vision API for the first time
I want to align the significant figures in the Numpy array
I want to create a Dockerfile for the time being.
Python (from first time to execution)
See python for the first time
Start Django for the first time
I tried to describe the traffic in real time with WebSocket
For the time being, I want to convert files with ffmpeg !!
Code that I wish I had remembered when I participated in AtCoder for the first time (Reflection 1 for the next time)
I made a function to check if the webhook is received in Lambda for the time being
The story of returning to the front line for the first time in 5 years and refactoring Python Django
What I learned by writing a Python Pull Request for the first time in my life
[Addition] Vulnerability in git! I have to update! But yum doesn't have the latest version, and I got it from the source! Note when
Let's try Linux for the first time
I tried logistic regression analysis for the first time using Titanic data
A useful note when using Python for the first time in a while
[Hi Py (Part 1)] I want to make something for the time being, so first set a goal.
I want to use Ubuntu's desktop environment on Android for the time being (Termux version-Japanese input in desktop environment)
I searched for railway senryu from the data
Try adding an external module to pepper. For the time being, in requests.
The story that had nothing to do with partitions when I did disk backup with dd for the first time
[Note] Deploying Azure Functions for the first time
I tried to predict the horses that will be in the top 3 with LightGBM
I played with Floydhub for the time being
I bought Sipeed Lichee Zero so I set it up for the time being
Looking back on the machine learning competition that I worked on for the first time
If an exception occurs in the function, it will be transmitted to the caller 2
I tried to predict the change in snowfall for 2 years by machine learning
I searched for the skills needed to become a web engineer in Python
I want to store the result of% time, %% time, etc. in an object (variable)
[Python] I will upload the FTP to the FTP server.
If an exception occurs in the function, it will be transmitted to the caller 1
I want to display the progress in Python!
I referred to it when I got stuck in the django geodjango tutorial (editing)
Let's do it by dividing numpy without using the for statement
How to execute the sed command many times using the for statement
Do a search by image from the camera roll using Pythonista3
Let's display the map using Basemap
[Python] Multiplication table using for statement
For the first time in Numpy, I will update it from time to time
I thought it would be slow to use a for statement in NumPy, but that wasn't the case.