Numpy实现了一些用于减少多维字符串数组的函数吗?我知道它提供了一些用于多个数组字符串连接的功能,但我还没有找到有关字符串缩减的任何信息。
假设我有一个二维字符串数组:
np.array([['a', 'b', 'c'],['e','f','g']])
我希望你能将其转换为:
np.array(['a b c','e f g'])
有没有比使用for循环更好的方法,例如:
old_strings = np.array([['a', 'b', 'c'],['e','f','g']])
new_strings = np.array([])
for s in old_strings:
new_strings = np.append(new_strings, (' '.join(s)))
''.join(s)
就足够了? - jpp