我有一个包含 3 列的新闻数据集:lead_paragraph, _id, web_url。
以下代码返回与 id 和 News 匹配的行lead_paragraph。
ds = pd.read_csv("nytimes.csv")
def item(id):
return ds.loc[ds['_id'] == id]['lead_paragraph'].tolist()[0]
如何获得web_url也在lead_paragraph列表中?
尝试一种解决方案后出现错误
return ds.loc[ds['_id'] == id], ['web_url', 'lead_paragraph']].tolist()
^
SyntaxError: invalid syntax
慕工程0101907
慕森卡
随时随地看视频慕课网APP
相关分类