title: Adding a column to a pandas dataframe based on other columns
body: <p><strong>Problem description</strong></p>
  
  <p><em>Introductory remark: For the code have a look below</em></p>
  
  <p>Let's say we have a pandas dataframe consisting of 3 columns and 2 rows.
  I'd like to add a 4th column called 'Max_LF' that will consist of an array. The value of the cell is retrieved by having a look at the column 'Max_WD'. For the first row that would be 0.35 which will than be compared to the values in the column 'WD' where 0.35 can be found at the third position. Therefore, the third value of the column 'LF' should be written into the column 'Max_LF'. If the value of 'Max_WD' occures multiple times in 'WD', then all corresponding items of 'LF' should be written into 'Max_LF'.</p>
  
  <p><strong>Failed attempt</strong></p>
  
  <p>So far I had various attemps on first retrieving the index of the item in 'Max_WD' in 'WD'. After potentially retrieving the index the idea was to then get the items of 'LF' via their index:
  <code>df4['temp_indices'] = [i for i, x in enumerate(df4['WD']) if x == df4['Max_WD']]</code></p>
  
  <p>However, a ValueError occured:
  raise ValueError('Lengths must match to compare')
  ValueError: Lengths must match to compare</p>
  
  <p><strong>This is what the example dateframe looks like</strong></p>
  
  <p><code>df = pd.DataFrame(data={'LF': [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] , 'WD': [[0.28, 0.34, 0.35, 0.18], [0.42, 0.45, 0.45, 0.18], [0.31, 0.21, 0.41, 0.41]], 'Max_WD': [0.35, 0.45, 0.41]})</code></p>
  
  <p><strong>The expected outcome should look like</strong></p>
  
  <p><code>df=pd.DataFrame(data={'LF': [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] , 'WD': [[0.28, 0.34, 0.35, 0.18], [0.42, 0.45, 0.45, 0.18], [0.31, 0.21, 0.41, 0.41]], 'Max_WD': [0.35, 0.45, 0.41], 'Max_LF': [[3] ,[2,3], [3,4]]})</code></p>