PostIT

[Python/Data Analysis] Numpay - Universal Array Function - Day 7 본문

Python/Data Analysis

[Python/Data Analysis] Numpay - Universal Array Function - Day 7

shun10114 2017. 6. 8. 09:13

# [Python/Data Analysis] Numpay - Universal Array Function - Day 7

import numpy as np


arr =np.arange(11)

arr

    array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10])


np.sqrt(arr)

    array([ 0.        ,  1.        ,  1.41421356,  1.73205081,  2.        ,

            2.23606798,  2.44948974,  2.64575131,  2.82842712,  3.        ,

            3.16227766])


A = np.random.randn(10)

A

    array([-0.66405485,  0.28749254,  0.27305696,  0.22232217,  0.8804781 ,

            1.01018702, -0.15188718, -0.78006006, -1.5951455 , -0.79699985])


B = np.random.randn(10)

B

    array([ 1.2901295 ,  0.27894444,  0.87601362,  0.78304898,  0.55902046,

           -1.65844088, -0.05473313,  1.34328664,  0.68122746,  1.70479054])


# Binary Functions

np.add(A,B)

    array([ 0.62607465,  0.56643697,  1.14907058,  1.00537115,  1.43949856,

           -0.64825385, -0.20662031,  0.56322658, -0.91391804,  0.90779069])


np.maximum(A,B)

    array([ 1.2901295 ,  0.28749254,  0.87601362,  0.78304898,  0.8804781 ,

            1.01018702, -0.05473313,  1.34328664,  0.68122746,  1.70479054])



import webbrowser

website = 'https://docs.scipy.org/doc/numpy/reference/ufuncs.html#ufunc'

webbrowser.open(website)

    True


Comments