Python | Pandas DatetimeIndex.strftime() Last Updated : 24 Dec, 2018 Comments Improve Suggest changes Like Article Like Report Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.strftime() function convert to Index using specified date_format. The function return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Syntax: DatetimeIndex.strftime(date_format) Parameters : date_format : Date format string (e.g. ā%Y-%m-%dā). Return : Index of formatted strings Example #1: Use DatetimeIndex.strftime() function to convert the given DatetimeIndex object to the specified format. Python3 # importing pandas as pd import pandas as pd # Create the DatetimeIndex # Here 'Q' represents quarter end frequency didx = pd.DatetimeIndex(start ='2000-01-15 08:00', freq ='Q', periods = 4, tz ='Asia/Calcutta') # Print the DatetimeIndex print(didx) Output : Now we want to convert the given DatetimeIndex object to ('%B %d, %Y, %r') format. Python3 # change the datetime format. didx.strftime('% B % d, % Y, % r') Output : As we can see in the output, the function has changed the format of the DatetimeIndex object to the desired format. Example #2: Use DatetimeIndex.strftime() function to convert the given DatetimeIndex object to the specified format. Python3 # importing pandas as pd import pandas as pd # Create the DatetimeIndex # Here 'MS' represents month start frequency didx = pd.date_range(pd.Timestamp("2000-01-15 08:00"), periods = 5, freq ='MS') # Print the DatetimeIndex print(didx) Output : Now we want to convert the given DatetimeIndex object to ('%B %Y, %r') format. Python3 # change the datetime format. didx.strftime('% B % Y, % r') Output : As we can see in the output, the function has changed the format of the DatetimeIndex object to the desired format. Comment More infoAdvertise with us Next Article Python | Pandas DatetimeIndex.strftime() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-datetimeIndex Practice Tags : python Similar Reads Python | Pandas DatetimeIndex.time Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.time attribute outputs an Index object containing the time values 2 min read Python | Pandas DatetimeIndex.second Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.second attribute outputs an Index object containing the second va 2 min read Python | Pandas DatetimeIndex.year Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.year attribute outputs an Index object containing the value of ye 2 min read Python | Pandas DatetimeIndex.to_frame() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.to_frame() function create a DataFrame with a column containing t 2 min read Python | Pandas DatetimeIndex.day Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.day attribute outputs an Index object containing the days in each 2 min read Like