您可以使用DataFrame.replace http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html:
df = pd.DataFrame({'A':['\xa0','s','w'],
'B':['s','w','v'],
'C':['e','d','\xa0']})
print (df)
A B C
0 s e
1 s w d
2 w v
然后用于创建list
of lists
转变DataFrame
to numpy array
by values http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.values.html进而tolist
:
df.replace(u'\xa0',u'', regex=True, inplace=True)
#if need cast all values to str add astype
print (df.astype(str).values.tolist())
[['', 's', 'e'], ['s', 'w', 'd'], ['w', 'v', '']]