Skip to content

COMPAT: datetime parsing with locale #15215

Closed
@jreback

Description

@jreback

we recently adding testing under a non-US locale for all tests with a larger than 1 unicode character (chinese), here, not just slow (which we have had for a while), and IT (which doesn't show these issues).

#15208 fixes almost everything, but this remains.

You can easily repro this by adding to pandas/__init__.py at the top.

import locale
locale.setlocale(locale.LC_ALL, 'zh_CN.UTF-8')
======================================================================
ERROR: test_to_datetime_format_microsecond (pandas.tseries.tests.test_timeseries.TimeConversionFormats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/jreback/pandas/pandas/tseries/tools.py", line 407, in _convert_listlike
    values, tz = tslib.datetime_to_datetime64(arg)
  File "pandas/tslib.pyx", line 1756, in pandas.tslib.datetime_to_datetime64 (pandas/tslib.c:30671)
    raise TypeError('Unrecognized value type: %s' % type(val))
TypeError: Unrecognized value type: <class 'str'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/travis/build/jreback/pandas/pandas/tseries/tests/test_timeseries.py", line 5374, in test_to_datetime_format_microsecond
    result = to_datetime(val, format=format)
  File "/home/travis/build/jreback/pandas/pandas/tseries/tools.py", line 427, in to_datetime
    return _convert_listlike(np.array([arg]), box, format)[0]
  File "/home/travis/build/jreback/pandas/pandas/tseries/tools.py", line 410, in _convert_listlike
    raise e
  File "/home/travis/build/jreback/pandas/pandas/tseries/tools.py", line 377, in _convert_listlike
    errors=errors)
  File "pandas/tslib.pyx", line 3600, in pandas.tslib.array_strptime (pandas/tslib.c:58664)
    raise ValueError("time data %r does not match "
ValueError: time data '01-Apr-2011 00:00:01.978' does not match format '%d-%b-%Y %H:%M:%S.%f' (match)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsDatetimeDatetime data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions