title: How can I simplify multiple "append"?
body: <p>I'm doing nested looping. However, my code is kind of messy because I use a lot of append list. I just simplify my parameters to make them more comfortable to look. Is there any method to simplify the codes? Thanks a lot.</p>
  <p>Basically, <code>feature(person, term)[0]</code> is a def(), and it return a tuple of value, like this</p>
  <pre><code>(0     0.019130
   1     0.011670
   2     0.012957
   3     0.015715
  Name: Vol, dtype: float64,
  (0     0.019130
   1     0.011670
   2     0.012957
   3     0.015715
   Name: Fluc, dtype: float64)
  </code></pre>
  <p>Edit</p>
  <p>—————</p>
  <p>Let’s say we just want to loop this random_num()(a tuple) multiple times. And let’s forget <code>feature(person, term)[0]</code> , this is being replaced by <code>random_num() </code></p>
  <pre class="lang-py prettyprint-override"><code>volume_df = pd.DataFrame()
  fluc_df = pd.DataFrame()
  column = [&quot;apple&quot;, &quot;bababa&quot;, &quot;cc&quot;, &quot;dd&quot;, &quot;ee&quot;, &quot;ff&quot;]
  import random
  def random_num():
      nums = []
      for i in range(10):
          nums.append(random.random())
      nums = tuple(nums)
      return nums
  
  for leg in range(1, 2):
      volume_per = []
      fluctuation_per = []
  
      for person in range(1, 3):
          volume_note = []
          fluctuation_note = []
          for term in range(1, 7):
              volume_df = random_num()
              fluctuation_df = random_num()
              
              volume_note.append(volume_df)
              fluctuation_note.append(fluctuation_df)
    
          volume_per.append(volume_note)
          fluctuation_per.append(fluctuation_note)
          
      volume_df = [pd.DataFrame(i).T.set_axis(column[0], axis=1) for i in volume_per]   
      fluc_df = [pd.DataFrame(i).T.set_axis(column[0], axis=1) for i in fluctuation_per]
  </code></pre>
  <p>I feel like it's terrible if I have hundred index in <code>feature(person, term, leg)[index]</code>, and the reason is that I have so many append.</p>