Reputation: 307
I have a Dataframe df_final
with a column link df_final.link
.
The line below should take the links in each row of the DF and add what is returned (a string) to the column full_article
df_final['full_article'] = newspaper.fulltext(requests.get(df_final.link).text)
It works if I pass in manually a single URL in place of df_final.link
in my get()
, but doesn't seem to work otherwise, because it tries to pass all the series, not elements individually.
How can I do this?
Upvotes: 2
Views: 778
Reputation: 862511
Use Series.apply
with lambda function:
f = lambda x: newspaper.fulltext(requests.get(x).text)
df_final['full_article'] = df_final.link.apply(f)
Upvotes: 3