I have an ndarray generated with all the possible combinations of 3 array like this:
countries = ["AF"... "Zw"]
names = ["name1",... "nameN"]
var_type = ['var1', 'var2', 'var3']
combinations = np.array(np.meshgrid(names, var_type,countries)).T.reshape(-1, 3)
which gives an ndarray with the following result:
array([
['name1', 'var1', 'AF'],
['name1', 'var2', 'AF'],
['name1', 'var3', 'AF'],
...,
['nameN', 'var1', 'ZW'],
['nameN', 'var2', 'ZW'],
['nameN', 'var3', 'ZW']
])
And I want to join each individual sub-array to get a new array with the merged values like this:
array([
"name1-var1-AF",
"name1-var2-AF",
"name1-var3-AF",
...,
"nameN-var1-ZW",
"nameN-var2-ZW",
"nameN-var3-ZW"
])
But the only way I fond in google so far is with a for loop like this:
columns = []
for column in combinations:
columns.append(str('-'.join(column)))
is there a more vectorized way to do this??