pyspark.pandas.Series.str.zfill¶
- 
str.zfill(width: int) → pyspark.pandas.series.Series¶
- Pad strings in the Series by prepending ‘0’ characters. - Strings in the Series are padded with ‘0’ characters on the left of the string to reach a total string length width. Strings in the Series with length greater or equal to width are unchanged. - Differs from - str.zfill()which has special handling for ‘+’/’-‘ in the string.- Parameters
- widthint
- Minimum length of resulting string; strings with length less than width be prepended with ‘0’ characters. 
 
- Returns
- Series of object
- Series with ‘0’ left-padded strings. 
 
 - Examples - >>> s = ps.Series(['-1', '1', '1000', np.nan]) >>> s 0 -1 1 1 2 1000 3 None dtype: object - Note that NaN is not a string, therefore it is converted to NaN. The minus sign in ‘-1’ is treated as a regular character and the zero is added to the left of it ( - str.zfill()would have moved it to the left). 1000 remains unchanged as it is longer than width.- >>> s.str.zfill(3) 0 -01 1 001 2 1000 3 None dtype: object