title: How to give rows and column header to a list output from loop in Python?
body: <p>I have a small loop which gives me list of data for n number of segments. Below is the code:</p>
  <pre><code>for df_grp in df.groupby(['Segment']):
    grp_ci = 1.96 * np.std(grp['Conversion_Percentage'])/math.sqrt(len(grp['Conversion_Percentage']))
    grp_cvr = grp['Conversion_Percentage'].iloc[-1]
    grp_ci95plus = grp_cvr + grp_ci
    grp_ci95minus = grp_cvr - grp_ci
    stat = (grp_ci,grp_cvr,grp_ci95plus,grp_ci95minus)
    print(stat)
  </code></pre>
  <p>I basically want these 4 statistical outputs which I am getting here as a list which is shown below:</p>
  <pre><code>(0.7443617976588611, 8.349514563106796, 9.093876360765657, 7.605152765447935)
  (0.5279035518807871, 7.9468622035996574, 8.474765755480444, 7.418958651718871)
  </code></pre>
  <p>Here is the sample data groupbed by segment A, similarly for other segments. This particular subsets give the 4 stat values that I am calculating:</p>
  <pre><code>                 days       user      Conversion_Percentage
  0                0.0        618               2.942577
  1                1.0        638               3.037806
  2                2.0        662               3.152081
  3                3.0        686               3.266356
  4                4.0        726               3.456814
  5                5.0        835               3.975812
  6                6.0        915               4.356728
  7                7.0        971               4.623369
  8                8.0       1004               4.780497
  </code></pre>
  <p>But instead I want this to come in a tabular form. And most importantly I want to get row and column headers. I tried converting the list to dataframe:</p>
  <pre><code>  array = (grp_ci,grp_cvr,grp_ci95plus,grp_ci95minus)
    index_values = ['grp']
    column_values = ['ci','cvr','ci95plus','ci95minus']
    stat= pd.DataFrame(data = array, index = index_values, columns = column_values)
    print(stat)
  </code></pre>
  <p>But it gave me the error:</p>
  <pre><code>AttributeError: module 'pandas' has no attribute 'Dataframe'
  </code></pre>
  <p>I have already checked that I do not have named any file or script using the package names but still could not understand this error. I also changed my dataframe code many times to see if I am writing the code wrong but no luck. My grp which is segment is something that I want in row and as the 4 stats are calculated I want them in column header. Better if it is in tabulated form but at least I need headers. This will be better if I have a lot of segment values and I will have all my segments printed in each row of the 4 columns. Something like this:</p>
  <pre><code>      ci                  cvr                   ci95plus                    ci95minus
    
  A     0.7443617976588611  8.349514563106796     9.093876360765657           7.605152765447935
  
  B     0.5279035518807871  7.9468622035996574    8.474765755480444           7.418958651718871
  </code></pre>
  <p><strong>Edit: I changed Dataframe to DataFrame. Apologies for that. Now I am getting the error:</strong>
  ValueError: Shape of passed values is (4, 1), indices imply (1, 4)</p>