pandas.Series.str.ljust¶
Filling right side of strings in the Series/Index with an
additional character. Equivalent to str.ljust()
.
- param width
- int
Minimum width of resulting string; additional characters will be filled with
fillchar
- param fillchar
- str
Additional character for filling, default is whitespace
- return
filled : Series/Index of objects
Limitations¶
- This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff
between staying in JIT-region with that function or going back to interpreter mode.
Examples¶
Filling right side of strings in the Series with an additional character¶
import pandas as pd
from numba import njit
@njit
def series_str_ljust():
series = pd.Series(['dog', 'foo', 'bar']) # Series of 'dog', 'foo', 'bar'
out_series = series.str.ljust(5, '*')
return out_series # Expect series of 'dog**', 'foo**', 'bar**'
print(series_str_ljust())
$ python ./series/str/series_str_ljust.py
0 dog**
1 foo**
2 bar**
dtype: object
See also
- Series.str.rjust
Fills the left side of strings with an arbitrary character.
- Series.str.center
Fills boths sides of strings with an arbitrary character.
Todo
Add support of 32-bit Unicode for str.ljust()