Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

array-broadcasting

Can’t use /= on numpy array

December 25, 2023 by Tarik

As pointed out in the comment, the change from int (which is how a is created) to float (which is the result of /) is not allowed when using /=. To “fix” this the dtype of a just has to be a float from the beginning: a=np.array([2, 4, 6], dtype=np.float64) a/=2 print(str(a)) >>>array([1., 2., 3.])

Categories python Tags array-broadcasting, arrays, numpy, python Leave a comment

How do I use np.newaxis?

September 27, 2022 by Tarik

Simply put, numpy.newaxis is used to increase the dimension of the existing array by one more dimension, when used once. Thus, 1D array will become 2D array 2D array will become 3D array 3D array will become 4D array 4D array will become 5D array and so on.. Here is a visual illustration which depicts … Read more

Categories python Tags array-broadcasting, multidimensional-array, numpy, numpy-ndarray, python Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa