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 | %a | Weekday Name ( local ) |
| %A | Weekday Name ( in Full ) | |
| %w | Weekday as decimal number(0 Sun, 1 Mon,) | |
| %W | Week number of the year (00,53) Mon as first day of week | |
| %U | Week number of the year (00,53) Sun as first day of week | |
| Day | %d | Day of the month as number ( 01,02,31) |
| %j | Day of the year as number ( 001,284,336) | |
| Month | %b | Month name ( Oct, Nov) |
| %B | Month name ( October, November) | |
| %m | Month number (01,12) | |
| Year | %y | Year short 2 digit ( 01,20) |
| %Y | Year Full 4 digit ( 2001,2020) | |
| %f | Year Fiscal short 2 digit ( 01,20) | |
| %F | Year Fiscal Full 4 digit ( 2001,2020) | |
| Hour | %H | Hour 24 hour clock ( 01,23) |
| %I | Hour 12 hour clock ( 01,11) | |
| Minute | %M | Minute as number ( 00,01,59) |
| Second | %S | Second as decimal number ( 00,61) |
| AM/PM | %p | AM / PM local time |
| Time Zone | %Z | Time Zone name |
| Local | %x | Local Date |
| %X | Local Time | |
| %c | Local Date & Time | |
| Quater | %q | Quater as number ( 01,04) |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.