docs: def encode(df, encoding='utf8', verbosity=1):
      """If you try to encode each element individually with python, this would take days!"""
      if verbosity > 0:
          # pbar_i = 0
          pbar = progressbar.ProgressBar(maxval=df.shape[1])
          pbar.start()
      # encode strings as UTF-8 so they'll work in python2 and python3
      for colnum, col in enumerate(df.columns):
          if isinstance(df[col], pd.Series):
              if verbosity:
                  pbar.update(colnum)
              if df[col].dtype in (np.dtype('object'), np.dtype('U'), np.dtype('S')) and any(isinstance(obj, basestring) for obj in df[col]):
                  strmask = np.array([isinstance(obj, basestring) for obj in df[col]])
                  series = df[col].copy()
                  try:
                      series[strmask] = np.char.encode(series[strmask].values.astype('U'))
                  except TypeError:
                      print("Unable to convert {} elements starting at position {} in column {}".format(
                            sum(strmask), [i for i, b in enumerate(strmask) if b][:1], col))
                      raise
                  except (UnicodeDecodeError, UnicodeEncodeError):
                      try:
                          series[strmask] = np.array([eval(s, {}, {}) for s in series[strmask]])
                      # FIXME: do something different for unicode and decode errors
                      except (SyntaxError, UnicodeDecodeError, UnicodeEncodeError):
                          newseries = []
                          for s in series[strmask]:
                              try:
                                  newseries += [s.encode('utf8')]
                              except:
                                  print(u'Had trouble encoding {} so used repr to turn it into {}'.format(s, repr(transcode_unicode(s))))
                                  # strip all unicode chars are convert to ASCII str
                                  newseries += [transcode_unicode(s)]
                          # for dtype('U'): UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 207: ordinal not in r
                          series[strmask] = np.array(newseries).astype('O')
                  df[col] = series
                  # df[col] = np.array([x.encode('utf8') if isinstance(x, unicode) else x for x in df[col]])
  
              # WARNING: this takes DAYS for only 100k tweets!
              # series = df[col].copy()
              # for i, value in series.iteritems():   
  
              #     if isinstance(value, basestring):
              #         series[i] = str(value.encode(encoding))
              # df[col] = series
      if verbosity:
          pbar.finish()
      return df