title: Have a dataframe restart it's count for a particular column
body: <h2>The Overview:</h2>
  
  <p>In our project, we are working with a CSV file that contains some data. We will call it <a href="https://gist.githubusercontent.com/tisaconundrum2/ee85d5a3f28fbaf5cf64073823a8aa84/raw/eb7d0f3eb68638dd9023d832fda3fdc0eea43a42/smal.tsv" rel="nofollow noreferrer">smal.csv</a> It is a bit of a chunky file that will be later used for some other algorithms. (Here is the <a href="https://gist.github.com/tisaconundrum2/ee85d5a3f28fbaf5cf64073823a8aa84" rel="nofollow noreferrer">gist</a> in case the link to smal.csv is too badly formatted for your browser.)</p>
  
  <p>The file will be loaded like this</p>
  
  <pre><code>filename = "smal.csv"
  keyname = "someKeyname"
  self.data[keyname] = spectral_data(pd.read_csv(filename, header=[0, 1], verbose=True))
  </code></pre>
  
  <hr>
  
  <p>The spectral class looks like this. As you can see, we do not actually keep the dataframe as is.</p>
  
  <pre><code>class spectral_data(object):
      def __init__(self, df):
  
          try:
              uppercols = df.columns.levels[0]
              lowercols = list(df.columns.levels[1].values)
          except:
              df.columns = pd.MultiIndex.from_tuples(list(df.columns))
              uppercols = df.columns.levels[0]
              lowercols = list(df.columns.levels[1].values)
  
          for i, val in enumerate(lowercols):
              try:
                  lowercols[i] = float(val)
              except:
                  lowercols[i] = val
  
          levels = [uppercols, lowercols]
          df.columns.set_levels(levels, inplace=True)
          self.df = df
  </code></pre>
  
  <hr>
  
  <p>After we've loaded it we'd like to concatenate it with another set of data, also loaded like <code>smal.csv</code> was.</p>
  
  <p>Our concatenation is done like this.</p>
  
  <pre><code>new_df = pd.concat([self.data[dataSet1].df, self.data[dataSet2].df], ignore_index=True)
  </code></pre>
  
  <p>However, the <code>ignore_index=True</code> does not work, because the actual row that we are concatenating is not the index. However, we cannot simply remove the column, it is necessary for other parts of our program.</p>
  
  <h2>The Objective:</h2>
  
  <p>I'm trying to concatenate a couple of data frames together, however, what I thought was the index is not actually the index for the data frame. Thus the command </p>
  
  <pre><code>pd.concat([df1.df, df2.df], ignore_index=True)
  </code></pre>
  
  <p>will not work. I thought maybe using <code>iloc</code> to change each individual cell would work but I feel like this is not the most intuitive way to approach this.</p>
  
  <hr>
  
  <p>How can I get a data frame that looks like this</p>
  
  <pre><code>[396 rows x 6207 columns]
      Unnamed: 0_level_0                        meta  ...       wvl       
      Unnamed: 0_level_1                      Sample  ...   932.695 932.89
  0                    1                         NaN  ...    -12.33   9.67
  1                    2                         NaN  ...     11.94   3.94
  2                    3                         NaN  ...     -2.67  28.33
  3                    4                         NaN  ...     53.22 -13.78
  4                    1                         NaN  ...     43.28   
  5                    2                         NaN  ...     41.33  47.33
  6                    3                         NaN  ...    -21.94  12.06
  7                    4                         NaN  ...    -30.94  -1.94
  8                    5                         NaN  ...    -24.78  40.22
  </code></pre>
  
  <p>Turn into this.</p>
  
  <pre><code>[396 rows x 6207 columns]
      Unnamed: 0_level_0                        meta  ...       wvl       
      Unnamed: 0_level_1                      Sample  ...   932.695 932.89
  0                    1                         NaN  ...    -12.33   9.67
  1                    2                         NaN  ...     11.94   3.94
  2                    3                         NaN  ...     -2.67  28.33
  3                    4                         NaN  ...     53.22 -13.78
  4                    5                         NaN  ...     43.28   
  5                    6                         NaN  ...     41.33  47.33
  6                    7                         NaN  ...    -21.94  12.06
  7                    8                         NaN  ...    -30.94  -1.94
  8                    9                         NaN  ...    -24.78  40.22
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sbqSv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sbqSv.png" alt="enter image description here"></a></p>