str attribute contains most of the methods in string.

df['ID'] = df['ID'].str.zfill(15)

See more: http://pandas.pydata.org/pandas-docs/stable/text.html

Answer from Guangyang Li on Stack Overflow
🌐
w3resource
w3resource.com › pandas › series › series-str-zfill.php
Pandas Series: str.zfill() function - w3resource
May 20, 2026 - The str.zfill() function is used to pad strings in the Series/Index by prepending '0' characters. Strings in the Series/Index are padded with '0' characters on the left of the string to reach a total string length width.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pandas-series-str-zfill
Python | Pandas Series.str.zfill() - GeeksforGeeks
September 21, 2018 - In this example, a width of 8 is set and zeroes are prefixed to Salary column using zfill() method. Since the Salary column has data type of int64, it's converted to string first using astype() method. ... # importing pandas import pandas as pd # making data frame from csv at url data = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/employees.csv") # converting to string dtype data["Salary"]= data["Salary"].astype(str) # width of output string width = 10 # calling method and overwriting series data["Salary"]= data["Salary"].str.zfill(width) # display data Output: As shown in the output image, zeroes have been prefixed and length of every string in salary column is 10 now.
🌐
Medium
medium.com › @amit25173 › pandas-zfill-guide-02024316d840
Pandas zfill Guide. The biggest lie in data science? That… | by Amit Yadav | Medium
April 12, 2025 - You’re probably familiar with the need for data to have a consistent format. Well, that’s where pandas zfill comes in. This handy function allows you to pad strings with zeros, so they have the same length.
🌐
Statology
statology.org › home › how to use zfill() function in pandas
How to Use zfill() Function in Pandas
April 19, 2024 - #prepend '0' characters to strings in sales column with minimum width of 4 df['sales'].str.zfill(width=4) 0 0120 1 1450 2 0080 3 0075 4 0075 5 0138 6 1200 Name: sales, dtype: object
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.22 › generated › pandas.Series.str.zfill.html
pandas.Series.str.zfill — pandas 0.22.0 documentation
Filling left side of strings in the Series/Index with 0. Equivalent to str.zfill(). index · modules | next | previous | pandas 0.22.0 documentation » ·
Find elsewhere
🌐
Databricks
api-docs.databricks.com › python › pyspark › latest › pyspark.pandas › api › pyspark.pandas.Series.str.zfill.html
pyspark.pandas.Series.str.zfill — PySpark master documentation
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.
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.25.0 › reference › api › pandas.Series.str.zfill.html
pandas.Series.str.zfill — pandas 0.25.0 documentation
Pandas arrays · Panel · Index objects · Date offsets · Frequencies · Window · GroupBy · Resampling · Style · Plotting · General utility functions · Extensions · Development · Release Notes · Enter search terms or a module, class or function name. Series.str.zfill(self, width)[source]¶ ·
🌐
Intelpython
intelpython.github.io › sdc-doc › latest › _api_ref › pandas.Series.str.zfill.html
pandas.Series.str.zfill — Intel® Scalable Dataframe Compiler 0.1 documentation
import pandas as pd from numba import njit @njit def series_str_zfill(): series = pd.Series(['dog', 'foo', 'bar']) # Series of 'dog', 'foo', 'bar' out_series = series.str.zfill(5) return out_series # Expect series of '00dog', '00foo', '00bar' print(series_str_zfill())
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.16.0 › generated › pandas.Series.str.zfill.html
pandas.Series.str.zfill — pandas 0.16.0 documentation
Contributing to pandas · Internals · Release Notes · Enter search terms or a module, class or function name. Series.str.zfill(width)¶ · ” Filling left side with 0 · index · modules | next | previous | pandas 0.16.0 documentation » · API Reference » ·
🌐
Codepointtech
codepointtech.com › home › mastering data formatting: how to use zfill() function in pandas
Mastering Data Formatting: How to Use zfill() Function in Pandas - codepointtech.com
July 4, 2026 - The zfill() method is a built-in ... the zero-padding happens after the sign character, not before it. In the context of Pandas, you typically access this function through the .str accessor on a Series....
🌐
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.pandas › api › pyspark.pandas.Series.str.zfill.html
pyspark.pandas.Series.str.zfill — PySpark 4.2.0 documentation
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).
🌐
datagy
datagy.io › home › python posts › python strings › python zfill & rjust: pad a string in python
Python zfill & rjust: Pad a String in Python • datagy
December 16, 2022 - In this tutorial, you’ll learn how to use Python’s zfill method to pad a string with leadering zeroes. You’ll learn how the method works and how to zero pad a string and a number. You’ll also learn how to use the method in Pandas as well as how to use sign prefixes, such as + or -, in your padding.