I have a data set of news with 3 columns: lead_paragraph, _id, web_url.
The following code returns a row matching the id along with News lead_paragraph.
ds = pd.read_csv("nytimes.csv")
def item(id):
return ds.loc[ds['_id'] == id]['lead_paragraph'].tolist()[0]
How to get web_url also with lead_paragraph in the list?
Got an error after trying one solution
return ds.loc[ds['_id'] == id], ['web_url', 'lead_paragraph']].tolist()
^
SyntaxError: invalid syntax
df.loc[ds['_id'] == id], ['x', 'y', 'z']].tolist()[0]