如何获取包含特定单词的行?
我正在使用netfilx dataset 。由Victor Soeiro上传到Kaggle。我想根据流派制作新数据集。例如,如果类型包含Word ['Comedy']或['Comedy','Fantasy'],我想要新的数据框。
my_code
df_comedy = df[df['genres'].str.extract("'comedy'")]
它给了我这个错误。 valueerror:模式不包含捕获组
如果您不了解我的问题,请我提供更多信息。
谢谢。
I'm using netfilx dataset. uploaded by VICTOR SOEIRO on KAGGLE. I want to make new datasets based on genres . For example, I want new dataframe if genres contain word ['comedy'] or ['comedy','fantasy'].
My_code
df_comedy = df[df['genres'].str.extract("'comedy'")]
It gives me this error. ValueError: pattern contains no capture groups
Ask me to provide more information, If you don't understand my question.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是解决您的问题的解决方案:
输出:
使用
包含
而不是提取
,您将获得答案。Here is Solution for your problem:
output:
Use
contains
instead ofextract
, you will get your answer.