title: pandas concatenate part of index in row attending condition
body: <p>I have a table listing in rows invoices and in rows kind of reparation and also power of the engine</p>
  
  <p>The power of the engine contains always the symbol '/'</p>
  
  <p>so filtering the index I have:</p>
  
  <p><a href="https://i.stack.imgur.com/rcdq4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rcdq4.png" alt="enter image description here"></a></p>
  
  <p>What I desire is a new row containing for every invoice a list of the different powers</p>
  
  <p>For instance for 'inv123' the new row should contain ['400/HP','500kw/h']</p>
  
  <p>So far I have the following code:
  from itertools import compress</p>
  
  <pre><code> boolean_filter = DF.index.str.contains('/') &amp; DF['inv123']
   indexlist =list(DF.index)
   mylist = list(compress(indexlist, boolean_filter))
   # you can generate it in one liner
   mylist = list(compress(DF.index,DF.index.str.contains('/') &amp; DF['inv123']))
  
  print(mylist)
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>['400/HP', '500/kwh']
  </code></pre>
  
  <p>This is the value I have to add in row='concatenate" column='inv123'</p>
  
  <p>I encounter a number of problems</p>
  
  <ul>
  <li>a) I am not able to that in a pythonic way (no loops)</li>
  <li><p>b) when adding an empty row with:</p>
  
  <p>DF.append(pd.Series(name='concatenate'))</p></li>
  </ul>
  
  <p>the dtype of the 0s,1s (integers) changes to float, which makes the code not reusable (not being boolean anymore)</p>
  
  <p>Some idea how to approach the problem?</p>
  
  <p>But still I would have to loop over every column</p>