pandas.tseries.api.guess_datetime_format#
- pandas.tseries.api.guess_datetime_format(dt_str, dayfirst=False)#
Guess the datetime format of a given datetime string.
- Parameters:
- dt_strstr
Datetime string to guess the format of.
- dayfirstbool, default False
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).
- Returns:
- str or Noneret
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')