- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy Compiler
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.broadcast_to
This function broadcasts an array to a new shape. It returns a read-only view on the original array. It is typically not contiguous. The function may throw ValueError if the new shape does not comply with NumPy's broadcasting rules.
Note − This function is available version 1.10.0 onwards.
The function takes the following parameters.
numpy.broadcast_to(array, shape, subok)
Example
import numpy as np a = np.arange(4).reshape(1,4) print 'The original array:' print a print '\n' print 'After applying the broadcast_to function:' print np.broadcast_to(a,(4,4))
It should produce the following output −
[[0 1 2 3] [0 1 2 3] [0 1 2 3] [0 1 2 3]]
numpy_array_manipulation.htm
Advertisements