def str_pad(arr, width, side='left', fillchar=' '):
 if (not isinstance(fillchar, compat.string_types)):
  msg = 'fillchar must be a character, not {0}'
  raise TypeError(msg.format(type(fillchar).__name__))
 if (len(fillchar) != 1):
  raise TypeError('fillchar must be a character, not str')
 if (not is_integer(width)):
  msg = 'width must be of integer type, not {0}'
  raise TypeError(msg.format(type(width).__name__))
 if (side == 'left'):
  f = (lambda x: x.rjust(width, fillchar))
 elif (side == 'right'):
  f = (lambda x: x.ljust(width, fillchar))
 elif (side == 'both'):
  f = (lambda x: x.center(width, fillchar))
 else:
  raise ValueError('Invalid side')
 return _na_map(f, arr)

def str_pad ( arr , width , side = 'left' , fillchar = ' ' ) : if ( not isinstance ( fillchar , compat . string_types ) ) : msg = 'fillchar must be a character, not {0}' raise TypeError ( msg . format ( type ( fillchar ) . __name__ ) ) if ( len ( fillchar ) != 1 ) : raise TypeError ( 'fillchar must be a character, not str' ) if ( not is_integer ( width ) ) : msg = 'width must be of integer type, not {0}' raise TypeError ( msg . format ( type ( width ) . __name__ ) ) if ( side == 'left' ) : f = ( lambda x : x . rjust ( width , fillchar ) ) elif ( side == 'right' ) : f = ( lambda x : x . ljust ( width , fillchar ) ) elif ( side == 'both' ) : f = ( lambda x : x . center ( width , fillchar ) ) else : raise ValueError ( 'Invalid side' ) return _na_map ( f , arr )
pad strings in the series/index with an additional character to specified side .