I'm attempting to use a lambda, along with a function, to search and return a specific value from a dataframe. Any idea how to procede? Is there a way to pass the entire df into the lambda, or is that bad practice? I've attached my attempted code here. any help would be greatly appreciated
My code is based on this:https://stackoverflow.com/a/66145080/10671347
except my data frame has values that sometimes repeat, and sometimes a row will now have value I'm searching for
def    getvalue(col1value,col2value): #i check to see if col1value matches a hard coded value, and if so, I return a single value from the original dataframe
        if colvalue1=='HardcodedValue':
           return df.loc[df['col2']==colvalue2,col3value].iloc[0] #fetches value, since it returns a series i grab the first match
        else:
           return 0
    
    df['new']=df.apply(lambda row: getvalue(row['col1'],row['col2']))
     
