สมัครเรียนโทร. 085-350-7540 , 084-88-00-255 , ntprintf@gmail.com

Tutorial Python Numpy

LM01PYTHON NUMPY INTRODUCTION LM02PYTHON NUMPY GETTING STARTED LM03PYTHON NUMPY ARRAYS INDEXING LM04PYTHON NUMPY ARRAYS SLICING LM05PYTHON NUMPY DATATYPE LM06PYTHON NUMPY ARRAYd COPY VS VIEW LM07PYTHON NUMPY ARRAY SHAPE LM08PYTHON NUMPY ARRAY RESHAPING LM09PYTHON NUMPY ARRAY ITERATING LM10PYTHON NUMPY JOINING ARRAY LM12PYTHON NUMPY SEARCHING ARRAYS LM13PYTHON NUMPY SORTING ARRAYS LM14PYTHON NUMPY FILTER ARRAY LM16PYTHON 10NUMPY TRIGONOMETRIC FUNCTIONS LM16PYTHON 11NUMPY HYPERBOLIC FUNCTIONS LM16PYTHON 12NUMPY SET OPERATIONS LM16PYTHON 1CREATE YOUR OWN UFUNC LM16PYTHON 2SIMPLE ARITHMETIC LM16PYTHON 3ROUNDING DECIMALS LM16PYTHON 4NUMPY LOGS LM16PYTHON 5NUMPY SUMMATIONS LM16PYTHON 6NUMPY PRODUCTS LM16PYTHON 7NUMPY DIFFERENCES LM16PYTHON 8NUMPY LCM LM16PYTHON 9NUMPY GCD

NumPy Products

เรียนเขียนโปรแกรมง่ายๆกับ Expert Programming Tutor ในบท numpy Product 
ในการหาproductขององค์ประกอบในอาร์เรย์ให้ใช้ฟังก์ชัน prod()
ตัวอย่าง
หา product ขององค์ประกอบของสองอาร์เรย์

import numpy as np
arr = np.array([1, 2, 3, 4])
x = np.prod(arr)
print(x)

ผลลัพธ์

24

การหาproduct ตามแกน
ถ้านักเรียนระบุ axis = 1, NumPy จะส่งคืน product ของแต่ละอาร์เรย์
ตัวอย่าง
ทำการสรุปในอาร์เรย์ต่อไปนี้ตามแกนที่ 1

import numpy as np
arr1 = np.array([1, 2, 3, 4])
arr2 = np.array([5, 6, 7, 8])
newarr = np.prod([arr1, arr2], axis=1)
print(newarr)

ผลลัพธ์

[24 1680]

Product Cummulative หมายถึงการนำproduct บางส่วน เช่น product บางส่วนของ [1, 2, 3, 4] คือ [1, 1 * 2, 1 * 2 * 3, 1 * 2 * 3 * 4] = [1, 2, 6, 24]
- ผลรวมบางส่วนของ Perfom กับฟังก์ชัน cumprod ()
ตัวอย่าง
ใช้product cummulative ขององค์ประกอบทั้งหมดสำหรับอาร์เรย์ต่อไปนี้

import numpy as np
arr = np.array([5, 6, 7, 8])
newarr = np.cumprod(arr)
print(newarr)

ผลลัพธ์

[ 5   30  210 1680]

เป็นอย่างไรกันบ้าง บทนี้เข้าใจกันไหม อย่าลืมไปศึกษาเพิ่มเติมกันได้เองเลยนะครับ
แปลจากhttps://www.w3schools.com/python/numpy_ufunc_products.asp



บทความนี้อาจจะมีที่ผิด กรุณาตรวจสอบก่อนใช้

หากมีข้อผิดพลาด/ต้องการพูดคุยเพิ่มเติมเกี่ยวกับบทความนี้ กรุณาแจ้งที่ http://m.me/Expert.Programming.Tutor

ไม่อยากอ่าน Tutorial อยากมาเรียนเลยทำอย่างไร?

สมัครเรียน ONLINE ได้ทันทีที่ https://elearn.expert-programming-tutor.com

หรือติดต่อ

085-350-7540 (DTAC)
084-88-00-255 (AIS)
026-111-618
หรือทาง EMAIL: NTPRINTF@GMAIL.COM

แผนที่ ที่ตั้งของอาคารของเรา

C Article


C++ Article


Java Article


C#.NET Article


VB.NET Article


Python Article


Golang Article


JavaScript Article


Perl Article


Lua Article


Rust Article


Article


Python


Python Numpy


Python Machine Learning



แผนผังการเรียนเขียนโปรแกรม

Link อื่นๆ

Allow sites to save and read cookie data.
Cookies are small pieces of data created by sites you visit. They make your online experience easier by saving browsing information. We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.

Copyright (c) 2013 expert-programming-tutor.com. All rights reserved. | 085-350-7540 | 084-88-00-255 | ntprintf@gmail.com

ติดต่อเราได้ที่

085-350-7540 (DTAC)
084-88-00-255 (AIS)
026-111-618
หรือทาง EMAIL: NTPRINTF@GMAIL.COM
แผนที่ ที่ตั้งของอาคารของเรา