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
  • 143,180
  • 12
  • 188
  • 271
Julian Avila
  • 105
  • 10

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
  • 110,290
  • 27
  • 149
  • 241