0

I need to build a way to automate file names, and I was curious as to if there is a function or a quick way to take in 8 digits and output the corresponding Date.

Specifically I only need the Month and year.

Example: 03232021 -> Mar2021

I was trying pandas to_datetime but it didn't seem like it was what I needed.

ShadowRanger
  • 124,179
  • 11
  • 158
  • 228

1 Answers1

3
In [133]: s = "03232021"                                                                                                                                                                                                                                                      

In [134]: dt.datetime.strptime(s, "%m%d%Y").date()                                                                                                                                                                                                                            
Out[134]: datetime.date(2021, 3, 23)
inspectorG4dget
  • 104,525
  • 25
  • 135
  • 234