def test_guess_datetime_format_no_padding(string, fmt): # see gh-11142 result = parsing.guess_datetime_format(string) assert result == fmt
def _guess_datetime_format_for_array(arr, **kwargs): # Try to guess the format based on the first non-NaN element non_nan_elements = notna(arr).nonzero()[0] if len(non_nan_elements): return guess_datetime_format(arr[non_nan_elements[0]], **kwargs)
def test_guess_datetime_format_invalid_inputs(invalid_dt): # A datetime string must include a year, month and a day for it to be # guessable, in addition to being a string that looks like a datetime. assert parsing.guess_datetime_format(invalid_dt) is None
def test_guess_datetime_format_with_locale_specific_formats(string, fmt): result = parsing.guess_datetime_format(string) assert result == fmt
def test_guess_datetime_format_with_dayfirst(dayfirst, expected): ambiguous_string = "01/01/2011" result = parsing.guess_datetime_format(ambiguous_string, dayfirst=dayfirst) assert result == expected
def test_guess_datetime_format_with_parseable_formats(string, fmt): result = parsing.guess_datetime_format(string) assert result == fmt
def _guess_datetime_format_for_array(arr, dayfirst: bool | None = False): # Try to guess the format based on the first non-NaN element non_nan_elements = notna(arr).nonzero()[0] if len(non_nan_elements): return guess_datetime_format(arr[non_nan_elements[0]], dayfirst=dayfirst)