code: def _reduce_and_smooth(obs_tidy, goal_size):
      
      if obs_tidy.shape[0] < goal_size:
          return obs_tidy
      else:
          # usually, a large number of cells can not be plotted, thus
          # it is useful to reduce the number of cells plotted while
          # smoothing the values. This should be similar to an interpolation
          # but done per row and not for the entire image.
          from scipy.interpolate import UnivariateSpline
          x = range(obs_tidy.shape[0])
          # maximum number of cells to keep
          new_x = np.linspace(0, len(x), num=goal_size, endpoint=False)
          new_df = obs_tidy.iloc[new_x, :].copy()
          for index, col in obs_tidy.iteritems():
              spl = UnivariateSpline(x, col.values, s=20)
              new_df[index] = spl(new_x)
          return new_df.copy()
docs: Uses interpolation to reduce the number of observations (cells).
      This is useful for plotting functions that otherwise will ignore
      most of the cells' values.
  
      The reduction and smoothing is only done per column
  
      Parameters
      ----------
      obs_tidy : Pandas DataFrame. rows = obs (eg. cells), cols = vars (eg. genes)
      goal_size : number of cells to keep
  
      Returns
      -------