Answers for "string to numpy array python"

6

python string to array

>>> text = 'a b c'
>>> text = text.split(' ')
>>> text
[ 'a', 'b', 'c' ]
Posted by: Guest on May-10-2020
1

string to array python

str = "MillieB11"
arr = list(str)
print(arr)
#['M', 'i', 'l', 'l', 'i', 'e', 'B', '1', '1']
Posted by: Guest on November-27-2021
0

pandas convert string to numpy array

import pandas as pd
import numpy as np

x = str(np.arange(1,100))
df = pd.DataFrame([x,x,x,x])
df.columns = ['words']
print 'sample'
print df.head()
result = df['words'].apply(lambda x: 
                           np.fromstring(
                               x.replace('n','')
                                .replace('[','')
                                .replace(']','')
                                .replace('  ',' '), sep=' '))
print 'result'
print result
Posted by: Guest on November-18-2021

Code answers related to "string to numpy array python"

Python Answers by Framework

Browse Popular Code Answers by Language