Shortest way to replace parts of strings in NumPy array

arrays, numpy, python

Solution

Use python list comprehension:

L = ['HD\,315', 'HD\,318' ]
print [s.replace('HD\,' , 'HD ') for s in L]

But it uses `for`

Alternatively you can use map():

print map(lambda s: s.replace('HD\,' , 'HD '), L)

for python3 use `list(map(lambda s: s.replace('HD\,' , 'HD '), L))`

Problem

I have a NumPy string array ``` ['HD\,315', 'HD\,318' ...] ``` I need to replace every 'HD\,' to 'HD ', i.e. I want to get new array like below ``` ['HD 315', 'HD 318' ...] ``` What is the SHORTEST way to solve this task in Python? Is it possible to do this without FOR loop?

Original source