You can use itertools.zip_longest:
import itertools
np.array(list(itertools.zip_longest(*v, fillvalue=0))).T
Out:
array([[1, 0],
[1, 2]])
Note: For Python 2, it is itertools.izip_longest.
More Related Contents:
- Dump a NumPy array into a csv file
- Numpy array assignment with copy
- numpy matrix vector multiplication [duplicate]
- Repeating each element of a numpy array 5 times
- how does multiplication differ for NumPy Matrix vs Array classes?
- Ambiguity in Pandas Dataframe / Numpy Array “axis” definition
- How to split/partition a dataset into training and test datasets for, e.g., cross validation?
- How to create a numpy array of arbitrary length strings?
- Numpy modify array in place?
- Subsetting a 2D numpy array
- How to normalize a 2-dimensional numpy array in python less verbose?
- What is the difference between ndarray and array in NumPy?
- Removing elements from an array that are in another array
- Creating same random number sequence in Python, NumPy and R
- Stocking large numbers into numpy array
- check for identical rows in different numpy arrays
- pd.Timestamp versus np.datetime64: are they interchangeable for selected uses?
- Numpy: For every element in one array, find the index in another array
- Prevent numpy from creating a multidimensional array
- Inverting a numpy boolean array using ~
- Numpy minimum in (row, column) format
- Convert NumPy array to 0 or 1 based on threshold
- Cannot understand numpy argpartition output
- Using numpy ‘module’ object has no attribute ‘array’ [duplicate]
- Python: Split NumPy array based on values in the array
- Python, OpenCV: Increasing image brightness without overflowing UINT8 array
- Numpy Array Get row index searching by a row
- Creating a numpy array of 3D coordinates from three 1D arrays
- How to use Python multiprocessing Pool.map to fill numpy array in a for loop
- Is this the best way to add an extra dimension to a numpy array in one line of code?