Python Numpy

Numpy in Python

What is Numpy?

  • For numeric calculation of linear algebra and scientific computing
  • opensource so anyone can install and use Numpy package(module) for free
  • broadcasting: the data that has the different data type(shape) is possible to calculate with other data (vector)

Why is Numpy used?

  • Numpy is one of the powerful tools in python for calculation
  • Functions in Numpy module are very useful!

Some functions of Numpy

  1. arithmetic calculation function
  • prod() or cumprod(): mutliply
  • sum() or cumsum(): add
  • abs(): absolute value
  • square() or sqrt()
  • exp() (= exponential) or log()
  1. statistic calculation function
  • mean() / std() / var() / max() or min()
  1. logical calculation function
  • isnan()/unique()
  1. geometric calculation function
  • shape()
  • transpose()

Array in Numpy

  • the basic data type of numpy calculation
  • The calculation is relatively fast.

Indexing and Slicing in array of Numpy

  • This is the same as in the list data type.

Special shape of array

  • np.ones()
  • np.zeros()
  • the indentical matrix
    The two things, ones() and zeros() would be frequently used in data analysis.