Combine all elements of two arrays python

I have two arrays, and want to combine the ith elements in each one together:

import numpy as np
a = np.array(['a', 'b', 'c'])
b = np.array(['x', 'y', 'z'])

I want to return

array(['ax', 'by', 'cz'])

What is the function for this? Thx,

Answers


>>> import numpy as np
>>> a = np.array(['a', 'b', 'c'])
>>> b = np.array(['x', 'y', 'z'])
>>> c = np.array([i+j for i, j in zip(a, b)])
>>> c
array(['ax', 'by', 'cz'],
      dtype='|S2')

@DSM makes the point that if a and b had dtype=object you could simply add the two arrays together:

>>> a = np.array(["a", "b", "c"], dtype=object)
>>> b = np.array(["x", "y", "z"], dtype=object)
>>> c = a + b
>>> c
array([ax, by, cz], dtype=object)

Need Your Help

Exclude a column from JTable when sorting

java sorting jtable

So I basically do not want the second column to show up when I sort in my JTable or vice-versa. A picture is worth a thousands words so here is a picture to show you what I mean.

Find First Visible Column In Sheet

excel vba excel-vba

I have a VBA question that I have been struggling to answer. In a spreadsheet, I have several columns that I have hidden (A:O). I'd like to find the first visible column of the worksheet (in this c...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.