Left-pad the string column to width `len` with `pad`.

    >>> df = spark.createDataFrame([('abcd',)], ['s',])
    >>> df.select(lpad(df.s, 6, '#').alias('s')).collect()
    [Row(s=u'##abcd')]
356061
def lpad(col, len, pad):
    
    sc = SparkContext._active_spark_context
    return Column(sc._jvm.functions.lpad(_to_java_column(col), len, pad))
28924
def string_width(word: str) -> int:
    
    return sum(map(lambda x: 2 if east_asian_width(x) in 'FWA' else 1, word))
748638
def serialize(df, measurement, tag_columns=None, **extra_tags) -> bytes:
    """"""
    # Pre-processing
    if measurement is None:
        raise ValueError("Missing 'measurement'")
    if not isinstance(df.index, pd.DatetimeIndex):
        raise ValueError('DataFrame index is not DatetimeIndex')
    tag_columns = set(tag_columns or [])
    isnull = df.isnull().any(axis=1)

    # Make parser function
    tags = []
    fields = []
    for k, v in extra_tags.items():
        tags.append(f"{k}={escape(v, key_escape)}")
    for i, (k, v) in enumerate(df.dtypes.items()):
        k = k.translate(key_escape)
        if k in tag_columns:
            tags.append(f"{k}={{p[{i+1}]}}")
        elif issubclass(v.type, np.integer):
            fields.append(f"{k}={{p[{i+1}]}}i")
        elif issubclass(v.type, (np.float, np.bool_)):
            fields.append(f"{k}={{p[{i+1}]}}")
        else:
            # String escaping is skipped for performance reasons
            # Strings containing double-quotes can cause strange write errors
            # and should be sanitized by the user.
            # e.g., df[k] = df[k].astype('str').str.translate(str_escape)
            fields.append(f"{k}=\"{{p[{i+1}]}}\"")
    fmt = (f'{measurement}', f'{"," if tags else ""}', ','.join(tags),
           ' ', ','.join(fields), ' {p[0].value}')
    f = eval("lambda p: f'{}'".format(''.join(fmt)))

    # Map/concat
    if isnull.any():
        lp = map(f, _itertuples(df[~isnull]))
        rep = _replace(df)
        lp_nan = (reduce(lambda a, b: re.sub(*b, a), rep, f(p))
                  for p in _itertuples(df[isnull]))
        return '\n'.join(chain(lp, lp_nan)).encode('utf-8')
    else:
        return '\n'.join(map(f, _itertuples(df))).encode('utf-8')
1091049
private static String longToPaddedString(long v, int digitsColumnWidth) {
    int digitWidth = numDigits(v);
    StringBuilder sb = new StringBuilder();
    appendSpaces(sb, digitsColumnWidth - digitWidth);
    sb.append(v);
    return sb.toString();
  }
829873
def lineincols (inlist,colsize):
    
    outstr = ''
    for item in inlist:
        if type(item) != StringType:
            item = str(item)
        size = len(item)
        if size <= colsize:
            for i in range(colsize-size):
                outstr = outstr + ' '
            outstr = outstr + item
        else:
            outstr = outstr + item[0:colsize+1]
    return outstr
901801
def column_width(tokens):
    
    get_len = tools.display_len if PY3 else len
    lens = sorted(map(get_len, tokens or [])) or [0]
    width = lens[-1]

    # adjust for disproportionately long strings
    if width >= 18:
        most = lens[int(len(lens) * 0.9)]
        if most < width + 6:
            return most

    return width
869645
function(str, len, padChar) {
    str = stringIt(str);
    if (str.length >= len) {
      return str;
    }
    var padStr = getPadding(padChar, len);
    return str + padStr.substr(str.length - len);
  }
1225184
def pad(a, desiredlength):
    

    if len(a) >= desiredlength:
        return a

    islist = isinstance(a, list)
    a = np.array(a)
    diff = desiredlength - len(a)
    shape = list(a.shape)
    shape[0] = diff

    padded = np.concatenate([a, np.zeros(shape, dtype=a.dtype)])
    return padded.tolist() if islist else padded
1200655
private int getColumn(String str)
    {
        int ret = 0;

        // Find the end of the column characters
        int len = 0;
        for(int i = 0; 
            i < str.length() && str.charAt(i) >= 'A' && str.charAt(i) <= 'Z'; 
            i++, len++);

        // Calculate the column number
        int pos = 0;
        for(int i = len-1; i >= 0; i--, pos++)
        {
            char c = str.charAt(i);
            int col = (int)(c - '@');
            if(pos > 0)
                col *= 26*pos;
            ret += col;
        }

        return ret;
    }
1240047
public static String leftPad(final String value, final String pad, final int length) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        validate(pad, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        if (value.length() > length) {
            return value;
        }
        return append(repeat(pad, length - value.length()), value);
    }
1300989
def pad(self, string):
        
        size = len(string)
        target = size * (4.75 - size ** 0.27)
        pad_len = int(target) - size
        return string + self.LOREM[:pad_len] + "#"
1161798
def _make_df(rows):
    """"""

    # Make DataFrame
    df = pd.DataFrame(rows).set_index('ts')

    # TimeDelta Support: https://issues.apache.org/jira/browse/ARROW-835
    for column in df.columns:
        if(df[column].dtype == 'timedelta64[ns]'):
            print('Converting timedelta column {:s}...'.format(column))
            df[column] = df[column].astype(str)
    return df
75959
def pad(string, width, options={})
      supported = [:left, :right, :center]
      padder = options[:padder] || ' '
      align  = options[:align] || :left

      chars = string.to_s.chars.to_a
      if chars.length < width
        string = case :"#{align}"
        when :left
          string + (padder * (width - chars.length))
        when :right
          (padder * (width - chars.length)) + string
        when :center
          right = ((pad_length = width - chars.length).to_f / 2).ceil
          left = pad_length - right
          (padder * left) + string + (padder * right)
        else
          raise ArgumentError, "Alignment must be one of: #{supported.join(' ')}"
        end
      end
      string
    end
569122
def mode(self, **kwargs):
        
        axis = kwargs.get("axis", 0)

        def mode_builder(df, **kwargs):
            result = df.mode(**kwargs)
            # We return a dataframe with the same shape as the input to ensure
            # that all the partitions will be the same shape
            if not axis and len(df) != len(result):
                # Pad columns
                append_values = pandas.DataFrame(
                    columns=result.columns, index=range(len(result), len(df))
                )
                result = pandas.concat([result, append_values], ignore_index=True)
            elif axis and len(df.columns) != len(result.columns):
                # Pad rows
                append_vals = pandas.DataFrame(
                    columns=range(len(result.columns), len(df.columns)),
                    index=result.index,
                )
                result = pandas.concat([result, append_vals], axis=1)
            return pandas.DataFrame(result)

        func = self._prepare_method(mode_builder, **kwargs)
        new_data = self._map_across_full_axis(axis, func)

        new_index = pandas.RangeIndex(len(self.index)) if not axis else self.index
        new_columns = self.columns if not axis else pandas.RangeIndex(len(self.columns))
        new_dtypes = self._dtype_cache
        if new_dtypes is not None:
            new_dtypes.index = new_columns
        return self.__constructor__(
            new_data, new_index, new_columns, new_dtypes
        ).dropna(axis=axis, how="all")
379210
def left_join(input, **params):
    
    PARAM_COL_RIGHT = 'col.right'
    PARAM_COL_LEFT = 'col.left'
    PARAM_FIELD_JOIN = 'field.join'

    right_df = pd.DataFrame.from_records(input[params.get(PARAM_COL_RIGHT)])
    left_df = pd.DataFrame.from_records(input[params.get(PARAM_COL_LEFT)])
    join_on = params.get(PARAM_FIELD_JOIN)
    res = right_df.set_index(join_on, drop=False).join(left_df.set_index(join_on, drop=False), on=[join_on], rsuffix='_right')
    return Converter.df2list(res)
1298371
def pad(text, length):
    """"""
    text_length = wcswidth(text)

    if text_length < length:
        return text + ' ' * (length - text_length)

    return text
55733
def char_pad_trunc(data, maxlen):
    
    new_dataset = []
    for sample in data:
        if len(sample) > maxlen:
            new_data = sample[:maxlen]
        elif len(sample) < maxlen:
            pads = maxlen - len(sample)
            new_data = sample + ['PAD'] * pads
        else:
            new_data = sample
        new_dataset.append(new_data)
    return new_dataset