Jun-17-2019, 04:43 AM
I want to stack matrixs together with different numbers of columns
The way I can think of is:
1.Find out how many columns in a
2.Add empty columns to b
3.Stack them together
Is there another way to make it simpler?
The way I can think of is:
1.Find out how many columns in a
2.Add empty columns to b
3.Stack them together
Is there another way to make it simpler?
import numpy as np a = np.array([["A1", "B1", "C1"], ["A1", "B1", "C1"]]) b = np.array([["A2", "B2"], ["A2", "B2"]]) c = np.array([["A3", "B3"], ["A3", "B3"]]) print(np.vstack((a, b))) #This would not allowed, because a and b have different columns # The following Result is wanted # [['A2' 'B2' 'C2'] # ['A2' 'B2' 'C2'] # ['A3' 'B3' ''] # ['A3' 'B3' '']]