Data analysis related learning -1 numpy

Recap:

  Data analysis: the seemingly chaotic extracted some information about the data behind the study summed up

The inherent laws of objects

  Three Musketeers data analysis: numpy, pandas, matplotlb

  

  numpy is an extension library python language supports a number of dimensions of the array and matrix operations

 In addition, also for the operation of the array, it provides a large library of mathematical functions

One: Create ndarray

 Guide package

import numpy as np

1: Creating an array np.array ()

  1 => 1: Create a one-dimensional array

np.array ([1,2,3,4,5 ]) 


Output: 
Array ([ . 1, 2,. 3,. 4,. 5])

  1 => 2: Create a two-dimensional array

in:
np.array([[1,2,3],[4,'a',6],[6,7,8]])

out:
array([['1', '2', '3'],
       ['4', 'a', '6'],
       ['6', '7', '8']], dtype='<U11')

 

     Note: The default type for all data elements ndarray of numpy is the same.

         If passed into ladies included in the list of different types, the type of unity is unity

      priority:

        str>float>int

   2: Use the routines function to create np

    It contains the following common method of creating:

      2=>1:

      np.ones (shape, dtype = None, order = 'c') to create an array of Junichi

  

in:
np.ones(shape=(3,3))
out:

Out[9]:
array([[1., 1., 1.],
       [1., 1., 1.],
       [1., 1., 1.]])

      2=>2:

      np.zeros (shape, dtpye = None, order = 'c') to create an array of pure 0

in:
np.zeros(shape=(3,3))

out
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]])

     2=>3:

      np.full (shape, fill_value, dtype = None, order = 'c') to create a list of all the numbers are the same

in:
np.full(shape=(3,3),fill_value=100)
out:
array([[100, 100, 100],
       [100, 100, 100],
       [100, 100, 100]])

   2=>4:

      np.lispace(start,stop,num=50,endpoint=True. retstep=False, dtype=None)

      Arithmetic progression

    

np.linspace (1.100, num = 20)

 
Out[19]:
array([  1.        ,   6.21052632,  11.42105263,  16.63157895,
        21.84210526,  27.05263158,  32.26315789,  37.47368421,
        42.68421053,  47.89473684,  53.10526316,  58.31578947,
        63.52631579,  68.73684211,  73.94736842,  79.15789474,
        84.36842105,  89.57894737,  94.78947368, 100.        ])

 

Guess you like

Origin www.cnblogs.com/baili-luoyun/p/11013897.html