I have a list of DOIs and Journal titles in a csv, now in a dataframe. I'm trying to reconstruct the journal url for v1 of the articles using a function. What is the correct way to create a new column using a function that uses values from existing columns in the dataframe?
The dataframe looks like this:
PMID Journal DOI
1234 medRxiv 10.1101/2020.09.30.320762
2345 bioRxiv 10.1101/2020.05.26.117549
The function I created:
def createURL (doi, journal) :
url = 'https://www.'+journal+'.org/content/'+ str(doi)+'v1'
return url
My attempt to call the function:
#this returns a Key Error ('PMID')
for row in dfRxiv :
dfRxiv['URL'][row] = createURL(dfRxiv['DOI'][row], dfRxiv['Journal'][row])
I'm new to Python and I'm sure there's a better way to do this - I appreciate any help!