title: python crosstab function in a loop
body: <p>I am working in python for quiet a time, but stuck at simple problem.I have to run crosstab functions for different variables with same ID variable(masteruserid)</p>
  
  <pre><code>pd.crosstab(data['MasterUserId'],visittime_cat)
  pd.crosstab(data['MasterUserId'],week_cat)
  </code></pre>
  
  <p>Now I want to do the same about 7-8 times. Instead of calling the crosstab function recurvisely, I want to put inside a loop and generate a crosstab dataset for each iteration. I tried this, but was not successful</p>
  
  <pre><code>def cross_tab(id_col,field):
      col_names=['visittime_cat','week_cat','var3','var4']
      for i in col_names:
          'crosstab_{ }'.format(i)=pd.crosstab(id_col,i)
  </code></pre>
  
  <p>I want to generate datasets such as crosstab_visittime_cat,crosstab_week_cat or as crosstab_1, crosstab_2 and so on.</p>