title: Iterating & Concatenating 2 lists is taking up huge memory
body: <p>In Python 3, I am trying to generate a sequence in this format from 4 lists</p>
  
  <pre><code>&lt;yyyymmdd&gt;-&lt;1-200&gt;-&lt;1-20&gt;-&lt;1-13000&gt;
  
  20161201-1-1-1
  20161201-1-1-2
  20161201-1-1-3
  ..
  ..
  20161201-1-2-1
  20161201-1-2-2
  ..
  ..
  20161201-2-1-1
  20161201-2-1-2
  ..
  20161202-1-1-1
  20161202-1-1-2
  ..
  ..
  20190701-200-20-13000
  </code></pre>
  
  <p>first list is in a date range of <code>&lt;yyyymmdd to yyyymmdd&gt;</code>, the remaining 3 lists are in ranges <code>&lt;1-200&gt; &lt;1-20&gt; and &lt;1-13000&gt;</code>.</p>
  
  <p>All list values are in str format.</p>
  
  <p>Now I'm trying to this the following:</p>
  
  <pre><code>import itertools
  import pandas as pd
  
  all_dates = [d.strftime('%Y%m%d') for d in pd.date_range('20160119','20191226')]
  all_users = list(range(0,200))
  all_products = list(range(0,15))
  all_customers = list(range(0,13000))
  
  date_user_product_map = []
  date_user_product_customer_map = []
  
  for pair in itertools.product(all_dates,all_users, all_products):
      date_user_product_map.append('-'.join(pair))
  
  for pair in itertools.product(date_user_product_map,all_customers):
      date_user_product_customer_map.append('-'.join(pair))
  </code></pre>
  
  <p>The first concatenation of 3 lists is fast and low on memory.
  The second concatenation is just taking up huge memory and is getting killed.</p>
  
  <p>I tried running this on a 48 gig RAM system too but it seems no amount of memory is enough for this to run.</p>
  
  <p>I would like some help on solving this issue and also understanding why this needs so much memory. What am I doing wrong here?</p>
  
  <p><strong>UPDATE:</strong>
  <strong>(my requirement)</strong></p>
  
  <p>So, I have couple of dataframes which have few columns whose values in the format of the -&lt;1-200>-&lt;1-20>-&lt;1-13000> which is taking up to much space And hence I want to create the list of all possible values and then enumerate over and create a dictionary like below:</p>
  
  <p>-&lt;1-200>-&lt;1-20>-&lt;1-13000></p>
  
  <p>20161201-1-1-1 : 0
  20161201-1-1-2 : 1
  20161201-1-1-3 : 2
  ..
  ..
  20190701-200-20-12999 : n-1
  20190701-200-20-13000 : n</p>
  
  <p>and then replace the values of the dataframes to 1,2... n,n-1.</p>
  
  <p>Is there any other way to do this?</p>