Search this site
Embedded Files
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
  • More
    • Home
    • Courses
    • Contact

日本語  ❯

Lesson 5    ❮    Lesson List    ❮    Top Page

5.1 NumPy Arrays      

5.2 Index and Reshape     

❯  5.3  Universal Function      

5.4 Join, Split, and Transpose

5.5 Search and Filter      

⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
EXPECTED COMPLETION TIME
❲▹❳  Video   7m 4s
☷  Interactive readings   5m
✑  Practice 5.3 (G Colab)   25m

Applying Arithmetic Operations on Arrays

Universal functions (or ufunc) are NumPy functions that operate on the ndarray object. Many ufunc are related to mathematical operations between arrays.

Math operations such as
add()
subtract()
multiply()
divide()
power()
can be easily applied.

Computing Basic Statistics

amin(ar),  amax(ar)
return the minimum, maximum of an array.

sum(ar)
compute the sum of all elements.

mean(ar)
compute the arithmetic mean.

median(ar)
compute the median.

std(ar)
compute the standard deviation.

quantile(ar,q)
computes the q-th quantile of the data.

For 2-D array, you can add an extra argument:
axis=0 to compute the rows statistics
axis=1 to compute the columns statistics

Applying Trigonometric & Logarithmic Operations

e, pi
return the value of Euler's constant and pi.

sin(), cos() and tan()
take values in radians and produce the corresponding sin, cos and tan values.

sinh(), cosh() and tanh()
take values in radians and produce the corresponding sinh, cosh and tanh values.

log(), log10()
function to perform corresponding log at the base e and 10.

Applying Set Operations

unique()
return the unique elements from any array, e.g., create a set array. (should only be 1-D)

union1d(ar1, ar2)
find the union of ar1 and ar2.

intersect1d(ar1, ar2)
find the intersection of ar1 and ar2.

setdiff1d(ar1, ar2)
find the set difference of ar1 and ar2.

isin(ar1, ar2)
test whether each element of ar1 is also present in ar2.

(Note that Python set cannot be converted to ndarray)

©2023. All rights reserved.  Samy Baladram,
Graduate Program in Data Science - GSIS - Tohoku University
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse