title: Assigning value to items in group based on other items in the group
body: <p>I'm trying to assign a value to each row in a group based on whether the input string is at the start of another string in the group. For example, "hello" is at the start of "hello world", so both of those are assigned the 'TOGETHER' value. 'goodbye' is not assigned a 'TOGETHER' value because it is not at the start of another string in the group.</p>
  
  <pre><code>input = [('1', 'hello'),('1', 'goodbye'),('1', 'hola'),('1', 'hi'),('1', 'hello world'),('1', 'hello world, goodbye'),('1', 'hello world, goodbye earth'),('2', 'bonjour'),('2', 'gracias'),('2','bonjour madame')]
  spark.createDataFrame(input,['group','input']).show(10,truncate=False)
  </code></pre>
  
  <p>Here is the input:</p>
  
  <p><a href="https://i.stack.imgur.com/twTUD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/twTUD.png" alt="enter image description here"></a></p>
  
  <p>Below is the desired output:</p>
  
  <p><a href="https://i.stack.imgur.com/qACOn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qACOn.png" alt="enter image description here"></a></p>
  
  <p>I am using pyspark, but if someone knows how to implement this in python, then I can work to translate it to pyspark.</p>