DataFrame.strftime()

Generate Datetime format output .
import pandas as pd 
my_data=pd.date_range(start='10/20/2019', end='02/14/2020',freq='M')
df=my_data.strftime('%d-%b-%Y')
print(df)
We created one date range by using date_range() and then used strftime() to format the output. Here is the output
Index(['31-Oct-2019', '30-Nov-2019', '31-Dec-2019', '31-Jan-2020'], dtype='object')
Here is a list of directives can be used to create formatted output.
Weekday%aWeekday Name ( local )
%AWeekday Name ( in Full )
%wWeekday as decimal number(0 Sun, 1 Mon,)
%WWeek number of the year (00,53) Mon as first day of week
%UWeek number of the year (00,53) Sun as first day of week
Day%dDay of the month as number ( 01,02,31)
%jDay of the year as number ( 001,284,336)
Month%bMonth name ( Oct, Nov)
%BMonth name ( October, November)
%mMonth number (01,12)
Year%yYear short 2 digit ( 01,20)
%YYear Full 4 digit ( 2001,2020)
%fYear Fiscal short 2 digit ( 01,20)
%FYear Fiscal Full 4 digit ( 2001,2020)
Hour%HHour 24 hour clock ( 01,23)
%IHour 12 hour clock ( 01,11)
Minute%MMinute as number ( 00,01,59)
Second%SSecond as decimal number ( 00,61)
AM/PM%pAM / PM local time
Time Zone%ZTime Zone name
Local%xLocal Date
%XLocal Time
%cLocal Date & Time
Quater%qQuater as number ( 01,04)
Pandas date & time to_datetime() period_range() date_range()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer