Scipy Tips

  • In python lists copies the elements twice and power is not applicable but for numpy arrays we can directly use the power function

  • a*2 means multiply each element by 2

  • a**2 means square of each term on the array

  • a[a>4] = 4 assigns the element with value greater than 4 to 4

  • a.clip(0,1) makes the elements of the array that are greater than 1 to 1

  • Can handle non existing values too.. and also can check is.whatever_the_specification

  • can remove such values as well a[~np.nan(a)]

  • numpy cannot hold any type of data as the python lists do .dtype is fixed

  • sp.genfromtext(“path”, delimiter="\t")

  • sp.sum(sp.isnan(y)) where y contains one d data