我的数据帧具有以下值:
data_df
0 student
1 sample text
2 student
3 no students
4 sample texting
5 random sample
我使用regex提取单词为'student'的行,结果如下:
regexdf
0 student
2 student
我的目标是在主数据框中创建一个具有0和1值的新列。i、 e.第0行应该是1,第5行应该是零。(因为'regexdf'在第0行和第2行中有'student')如何匹配这两个行中的索引并创建列?你知道吗
Tags:
你也可以这样做
或者
如果你想要一个新的数据帧
使用正则表达式:
输出:
编辑
输出:
相关问题 更多 >
编程相关推荐