1

How can we get the format of datetime column in Pandas dataframe?

# This is how we set!
df["Date"] = df["Date"].strftime("%m-%d-%Y")

Now, how do I get it? as

df['Date'].?????

>>> "%m-%d-%Y"
s_mj
  • 530
  • 11
  • 28
  • so you have a string that represents a date (and time) and you want to derive the format? You could basically test a bunch of format directives and see if one parses the string - but at some point, I think you'll run into ambiguities (no matter how you do it): e.g. '10/11/12' could be y-m-d, d-m-y etc. – FObersteiner Dec 18 '20 at 08:01

0 Answers0