Skip to content
Advertisement

lookup for a value in one column and return from another column’s corresponding row in pands

I know it is a fundamental question, but I couldn’t solve it. Any help will be appreciated

My list1 has around 1059 values, list2 has around 7 values.

I want to check values in list1 against values in list2, if matches append ‘x’ to list variable, if not matches append ‘y’ to same list variable. So at the end I want size of my list variable to be equal to the size of list1.

JavaScript

But I am not getting as I wanted. I tried using break, continue everything, but it is not working.

  • When using break, it’s appending ‘y’ 6 times when it is not matching
  • When using continue, appending ‘I don’t know‘ many times.

Please find the image and script in the edited post I hope this can help to understand my issue. I have 1058 recordsin list1[ID] which is equal to one in list2['Positionnummer'], So when both equals I want to get corresponding value from list2['New Bewehrungsgehalt'] and append to out output list i.e value, if not equal append old(default) value to the list value. At the end I want len(list1) == len(value).

For example: in first iteration when U1.ST.XX from list1[ID] == U1.ST.XX from list2['Positionsnummer'] then value.append(New Bewehrungehalt) i.e '88888888'

Advertisement

Answer

Example Solution

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement