1.dataframe转成numpy array

把Pandas中的dataframe转成numpy中的array
df=df.values

2.series和dataframe转换

import pandas as pd
//y_pred是ndarray
//将ndarray转为series
pred = pd.Series(y_pred.tolist())
//y_test、content、都是series
dict = {'prediction':pred.values, '内容':y_test.values,'content':content.values}
df = pd.DataFrame(dict)

3.series转numpy array

series.values
或者
np.array(series)

参考:https://blog.csdn.net/weixin_43434202/article/details/108222426

posted on 2020-11-10 18:51  dLarger  阅读(5396)  评论(0编辑  收藏  举报