What I Learned Yesterday #8

Yesterday I was refreshing my knowledge of NumPy package:

  • NumPy – Numerical Python (didn’t know that)
  • NumPy arrays: contain only one type
  • Different types – different behavior: “string”+”string”=”stringstring”, 1+1=2, NumPy array + NumPy array = every element of each array will be added to each other: array([1,2,3])+array([1,2,3])=array([2,4,6])
  • Conditional selection in NumPy array – arr[arr > 1]
  • NumPy arrays are N-dimensional arrays
  • subsetting in 2D array: arr[0][2] – first square brackets – index of the row, second – index of the column
  • subsetting in 2D array: arr[:,2] – all rows of the second column
  • selecting range of indexes: arr[1:3] – first value including, second – excluding -> this command will select only first and second elements of the index
  • some useful basic statistics functions: mean(), median(), correlation coefficient – corrcoef(), standard deviation – std(), sum(), sort(), round()

Quite technical, but it really helped me to repeat the basics and highlight some things that were not straightforward to me.

Leave a Reply

Your email address will not be published. Required fields are marked *