Answers for "split string with numpy python"

0

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'
Posted by: Guest on June-13-2020

Code answers related to "split string with numpy python"

Python Answers by Framework

Browse Popular Code Answers by Language