title: Appending a DataFrame in a nested for loop without appending NaN values
body: <p>I have a nested for loop that iterates through a dictionary and pulls out specific slices of data and appends the slice into a new dictionary. I am not sure if this has something to do with the index on append or the amount of loops or neither. The code is shown below.</p>
  <pre><code>def combine_timesteps(channels, startpoint = 5):
      startpoint_start = startpoint
      endpoint = None
      
      timestep_dataset = pd.DataFrame({'Discharge': discharge_values_at_strain_times[startpoint:endpoint]}).transpose()
  
      for channel in channels.items():
          
          for i, time_data in enumerate(channel[1]):
                          
              data = channel[1][startpoint:endpoint]
              time_int_string = str(channel[0]) + ' t-' + str(i)
              df_to_append = pd.DataFrame({time_int_string:data})
  
              timestep_dataset = timestep_dataset.append(df_to_append[time_int_string])
              
              print(timestep_dataset)
              
              new_start = startpoint - 1
              startpoint = new_start
              
              if endpoint == None:
                  endpoint = 0
              new_end = endpoint - 1
              endpoint = new_end
              
              if startpoint == -1: 
                  startpoint = startpoint_start
                  endpoint = None
                  break
      
      timestep_dataset_formatted = timestep_dataset.transpose()      
      
      return timestep_dataset_formatted
  
  </code></pre>
  <p>However, whenever a new append happens, it slides the data that is appended down with amount NaN values equal to the startpoint integer in front as shown below.</p>
  <pre><code>Discharge           9.913190    9.908002    9.902636    9.897269    9.891902   
  Channel 750 t-0          NaN         NaN         NaN         NaN         NaN   
  Channel 750 t-1          NaN         NaN         NaN         NaN  259.839939   
  Channel 750 t-2          NaN         NaN         NaN  274.439453  259.839939   
  Channel 750 t-3          NaN         NaN  269.095527  274.439453  259.839939   
  Channel 750 t-4          NaN  363.006610  269.095527  274.439453  259.839939   
  Channel 750 t-5   977.719896  363.006610  269.095527  274.439453  259.839939   
  Channel 1300 t-0         NaN         NaN         NaN         NaN         NaN   
  Channel 1300 t-1         NaN         NaN         NaN         NaN  325.599363   
  Channel 1300 t-2         NaN         NaN         NaN  420.957686  325.599363   
  Channel 1300 t-3         NaN         NaN  376.701738  420.957686  325.599363   
  Channel 1300 t-4         NaN  444.503183  376.701738  420.957686  325.599363   
  Channel 1300 t-5  964.735686  444.503183  376.701738  420.957686  325.599363   
  </code></pre>
  <p>The desired output format is for the first value in the t-0 column to be the first non NaN value (basically sliding each column up spaces until there isn't a NaN value) and so on. I am unsure why the dataframe that is grabbed first and appended has the NaN values out front.</p>
  <pre><code>Discharge           9.913190    9.908002    9.902636    9.897269    9.891902   
  Channel 750 t-0   287.678547  264.190236  182.871974  208.402388  246.174055
  Channel 750 t-1   259.839939  287.678547  264.190236  182.871974  208.402388 
  Channel 750 t-2   274.439453  259.839939  287.678547  264.190236  182.871974 
  Channel 750 t-3   269.095527  274.439453  259.839939  287.678547  264.190236 
  Channel 750 t-4   363.006610  269.095527  274.439453  259.839939  287.678547
  Channel 750 t-5   977.719896  363.006610  269.095527  274.439453  259.839939   
  Channel 1300 t-0  362.181147  403.321962  423.858839  341.982210  237.443283   
  Channel 1300 t-1  325.599363  362.181147  403.321962  423.858839  341.982210 
  Channel 1300 t-2  420.957686  325.599363  362.181147  403.321962  423.858839 
  Channel 1300 t-3  376.701738  420.957686  325.599363  362.181147  403.321962 
  Channel 1300 t-4  444.503183  376.701738  420.957686  325.599363  362.181147 
  Channel 1300 t-5  964.735686  444.503183  376.701738  420.957686  325.599363   
  </code></pre>
  <p>Thanks for your help.</p>