title: how to set multilevel index to a dataframe when repeating rows
body: <p>This may not be a well-phrased question for this problem but here's what I got.
  In some intermediate calculation of a rather long data analysis I mistakenly setup column names when in fact I meant to have them as row values, so that I end up with a single-row dataframe:</p>
  <p><a href="https://i.stack.imgur.com/tGZSX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tGZSX.png" alt="enter image description here" /></a></p>
  <p><strong>vx_top</strong> being the column name for which I needed to have one row for each of the 11 values it takes.</p>
  <p>So to fix it, I create a new dataframe by repeating that row as many times as I have different values of <strong>vx_top</strong> (11 values here) while populating it with each of its different values in each new row:</p>
  <pre><code>df2 = df.iloc[:,0:14].loc[df.index.repeat(11)]
  df2['vx_top'] = vtop.iloc[0,:].values
  </code></pre>
  <p>which gives me (after adding some new columns):</p>
  <p><a href="https://i.stack.imgur.com/ckHTe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ckHTe.png" alt="enter image description here" /></a></p>
  <p>The problem is that an index shows up, thus different for each row. Yet there will be new single-row dataframes that will need to be fixed the same way as above and concatenated to the new block(s). Still, I want to have each new block of repeated rows easily accessible/queryable with an index value that is unique for that block.</p>
  <p>Is a multi-index the canonical way to do it? What's the simplest way to implement it in this context?</p>
  <p><strong>UPDATE 1:</strong>
  To address request in the comment, down below, pasting the sample of the single-row data as a dictionnary. Also, to clarify, <strong>vx_top</strong> values are associated to some other measurement values. So the new block gets a new column <strong>vx_top</strong> with these measurement values, and the numbers in the 11 <strong>vx_top</strong> column labels populate the new column called <strong>vx_drift</strong>. Each new block will have the same series of 11 values of <strong>vx_drift</strong>.
  A 1st workaround I found was to add a new column with one value that repeats over the 11 rows and I increment that number for each new block that I concatenate. That creates an index, with a unique value for each block. Using <code>drop_duplicates</code> later on gives me an unambiguous output.</p>
  <pre><code>{'rs': {0: 8},
   'intsteps': {0: 5},
   'ballspacing': {0: 8},
   'dp': {0: 0.25},
   'sigma_factor': {0: 1.0},
   'fourier_radius': {0: 10.0},
   'nframes': {0: 300},
   'kernel': {0: 'boxcar'},
   'fwhm': {0: 37},
   'p_top_0': {0: 2.9604998594446235},
   'p_top_1': {0: 0.0017769831469974316},
   'p_bot_0': {0: 2.9335609794958257},
   'p_bot_1': {0: 0.0027714058659887237},
   'vx_top -0.50': {0: -0.1682745949730143},
   'vx_top -0.40': {0: -0.13733172700812427},
   'vx_top -0.30': {0: -0.10498257509086492},
   'vx_top -0.20': {0: -0.06998030086694419},
   'vx_top -0.10': {0: -0.034314351692782234},
   'vx_top 0.00': {0: 0.0015197793336616842},
   'vx_top 0.10': {0: 0.03690927370738665},
   'vx_top 0.20': {0: 0.07096583535412622},
   'vx_top 0.30': {0: 0.10319037709107594},
   'vx_top 0.40': {0: 0.13434676971737652},
   'vx_top 0.50': {0: 0.16134897582145027}}
  </code></pre>
  <p><strong>UPDATE 2:</strong></p>
  <p>Here is what I get with the workaround explained in UPDATE 1, after creating a custom index (<strong>idx</strong>, last column) to each row of a new block, and dropping the duplicates later on to display an output to read only some block-relevant columns when I do not care about the <strong>vx_top</strong> values.</p>
  <pre><code>    rs  sigma_factor    fourier_radius  nframes     p_top_0     p_top_1     p_bot_0     p_bot_1     idx
  0   8   1.0     10.0    300     2.960500    0.001777    2.933561    0.002771    0
  22  8   1.0     5.0     300     4.572554    0.004632    4.438380    0.004271    2
  44  8   1.5     5.0     300     5.913322    0.004338    5.690720    0.003519    4
  55  8   1.5     10.0    300     3.574674    0.003546    3.505626    0.003217    5
  11  8   2.0     10.0    300     4.261935    0.003636    4.166161    0.002291    1
  33  8   2.0     5.0     300     7.493733    0.004573    7.171297    0.003586    3
  </code></pre>