title: Is it possible to split a column value and add a new column at the same time for dataframe?
body: <p>I have a dataframe with some columns delimited with '|', and I need to flatten this dataframe. Example:</p>
  <pre><code>name  type
  a      l
  b      m
  c|d|e  n
  </code></pre>
  <p>For this df, I want to flatten it to:</p>
  <pre><code>   name type
      a    l
      b    m
      c    n
      d    n
      e    n
  </code></pre>
  <p>To do this, I used this command:</p>
  <pre><code>df = df.assign(name=df.name.str.split('|')).explode(column).drop_duplicates()
  </code></pre>
  <p>Now, I want do one more thing besides above flatten operation:</p>
  <pre><code>   name type  co_occur
      a    l
      b    m
      c    n    d
      c    n    e
      d    n    e  
  </code></pre>
  <p>That is, not only split the 'c|d|e' into two rows, but also create a new column which contains a 'co_occur' relationship, in which 'c' and 'd' and 'e' co-occur with each other.</p>
  <p>I don't see an easy way to do this by modifying:</p>
  <pre><code>df = df.assign(name=df.name.str.split('|')).explode(column).drop_duplicates()
  </code></pre>