NumPy: broadcast_arrays() function
numpy.broadcast_arrays() function
The broadcast_arrays() function broadcasts any number of arrays against each other.
Syntax:
numpy.broadcast_arrays(*args, **kwargs)
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
*args | The arrays to broadcast. | Required |
subok | If True, then sub-classes will be passed-through, otherwise the returned arrays will be forced to be a base-class array (default). | Optional |
Return value:
broadcasted [list of arrays] These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Example: numpy.broadcast_arrays()
>>> import numpy as np
>>> a = np.array([[2,3,4]])
>>> b = np.array([[2],[3],[4]])
>>> np.broadcast_arrays(a, b)
[array([[2, 3, 4],
[2, 3, 4],
[2, 3, 4]]), array([[2, 2, 2],
[3, 3, 3],
[4, 4, 4]])]
Pictorial Presentation:
Python - NumPy Code Editor:
Previous: broadcast_to()
Next: expand_dims()
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework