📌  相关文章
📜  pandas 将字符串转换为 numpy 数组 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:50.057000             🧑  作者: Mango

代码示例1
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