我是python新手。我有这样一个数据帧:
name comment
0 A I enjoy this lovely moment.
1 B I can't believe this was the worst day ever.
2 C The hotel was amazing.
3 A I am overwhelmed by this lovely journey.
4 C Food is good as well as having a nice time.
...
我必须在该数据框中创建一个新列,并在该列中为每行填充一个名为“a”的变量
code for my dataset is:
a=pd.read\U csv(io.StringIO(r.decode('utf-8'))
Can you please help me please please.
要转换概率,请使用
在这里,你可以预测情绪
然后插入这个情绪变量,正如我在上面的第一条评论中解释的
好吧,我假设您有一个名为rawData的数据框架,它有两列
['name', comment']
。 要在rawData中添加新列,可以添加一行:您将得到具有三列的rawData,即
['name', comment', 'prediction']
您可以创建一个函数
predict
,该函数接收一条注释并返回预测值,然后使用以下代码创建一个新列:要在python中创建函数,语法如下:
相关问题 更多 >
编程相关推荐