code: def stack_sparse_frame(frame):
      
      lengths = [s.sp_index.npoints for _, s in frame.items()]
      nobs = sum(lengths)
  
      # this is pretty fast
      minor_codes = np.repeat(np.arange(len(frame.columns)), lengths)
  
      inds_to_concat = []
      vals_to_concat = []
      # TODO: Figure out whether this can be reached.
      # I think this currently can't be reached because you can't build a
      # SparseDataFrame with a non-np.NaN fill value (fails earlier).
      for _, series in frame.items():
          if not np.isnan(series.fill_value):
              raise TypeError('This routine assumes NaN fill value')
  
          int_index = series.sp_index.to_int_index()
          inds_to_concat.append(int_index.indices)
          vals_to_concat.append(series.sp_values)
  
      major_codes = np.concatenate(inds_to_concat)
      stacked_values = np.concatenate(vals_to_concat)
      index = MultiIndex(levels=[frame.index, frame.columns],
                         codes=[major_codes, minor_codes],
                         verify_integrity=False)
  
      lp = DataFrame(stacked_values.reshape((nobs, 1)), index=index,
                     columns=['foo'])
      return lp.sort_index(level=0)
docs: Only makes sense when fill_value is NaN