我有一个dataframe,df
,有3列,如下所示:
company | year | text
Apple | 2016 |"The Company sells its products worldwide through its..."
我想在df['text']
中搜索“products”,并提取“products”之前和之后的3个单词,并将前面和后面的3个单词分别插入数据框中的两列,df['before']
和{
这是我目前所做的:
^{pr2}$不过,我得到的信息是:
TypeError: expected string or buffer
我该怎么做?在
使用^{}
可以使用新列创建新的数据帧
^{pr2}$相关问题 更多 >
编程相关推荐