split string with numpy python code example
Example: split string with numpy python
# Split string inside numpay array
import numpy as np
# In this case I want to remove everything before " – "
# to stay only with --> "I have a friendly staff", "Friendly staff advice for..."
array = ['Linda Rodway – I have a friendly staff',
'Kevin Ransom – Friendly staff advice for...']
# Create numpy array
a = np.array(array)
# Now you can split using .split method and loop through all inside a
b = np.array([x.split(' – ')[1] for x in a])
# in this case if you remove [1] you will see the following result:
# 'Linda Rodway', 'I have a friendly staff', and you use [1] to show only
# the second one 'I have a friendly staff'