Guess the datetime format of a given datetime string.
Datetime string to guess the format of.
If True parses dates with the day first, eg 20/01/2005
Warning
dayfirst=True is not strict, but will prefer to parse with day first (this is a known bug).
datetime format string (for strftime or strptime), or None if it can’t be guessed.
Examples
>>> from pandas.tseries.api import guess_datetime_format
>>> guess_datetime_format('09/13/2023')
'%m/%d/%Y'
>>> guess_datetime_format('2023|September|13')
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.tseries.api.guess_datetime_format.html