【发布时间】:2018-12-21 18:44:44
【问题描述】:
我有 newspaper3k 的函数,它提取给定 url 的摘要。给定为:-
def article_summary(row):
url = row
article = Article(url)
article.download()
article.parse()
article.nlp()
text = article.summary
return text
我有一个名为url的列的熊猫数据框
url
https://www.xyssss.com/dddd
https://www.sbkaksbk.com/shshshs
https://www.ascbackkkc.com/asbbs
............
............
还有另一个函数main_code() 运行得非常好,我在其中使用article_summary。我想将article_summary 和main_code() 这两个函数添加到一个函数final_code 中。
这是我的代码:第一个函数为:-
def article_summary(row):
url = row
article = Article(url)
article.download()
article.parse()
article.nlp()
text = article.summary
return text
这是第二个功能
def main_code():
article_data['article']=article_data['url'].apply(article_summary)
return article_data['articles']
当我完成后:
def final_code():
article_summary()
main_code()
但是final_code() 没有给出任何输出,它显示为TypeError: article_summary() missing 1 required positional argument: 'row'
【问题讨论】:
标签: python-3.x pandas user-defined-functions python-newspaper