code: def percent_initiated_conversations(records):
      
      interactions = defaultdict(list)
      for r in records:
          interactions[r.correspondent_id].append(r)
  
      def _percent_initiated(grouped):
          mapped = [(1 if conv[0].direction == 'out' else 0, 1)
                    for conv in _conversations(grouped)]
          return mapped
  
      all_couples = [sublist for i in interactions.values()
                     for sublist in _percent_initiated(i)]
  
      if len(all_couples) == 0:
          init, total = 0, 0
      else:
          init, total = list(map(sum, list(zip(*all_couples))))
  
      return init / total if total != 0 else 0
docs: The percentage of conversations that have been initiated by the user.
  
      Each call and each text conversation is weighted as a single interaction.
  
      See :ref:`Using bandicoot <conversations-label>` for a definition of
      conversations.