Example #1
0
def test_guess_datetime_format_no_padding(string, fmt):
    # see gh-11142
    result = parsing.guess_datetime_format(string)
    assert result == fmt
Example #2
0
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)
Example #3
0
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
Example #4
0
def test_guess_datetime_format_with_locale_specific_formats(string, fmt):
    result = parsing.guess_datetime_format(string)
    assert result == fmt
Example #5
0
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
Example #6
0
def test_guess_datetime_format_with_parseable_formats(string, fmt):
    result = parsing.guess_datetime_format(string)
    assert result == fmt
Example #7
0
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)