Skip to content

COMPAT: datetime parsing with locale #15215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jreback opened this issue Jan 24, 2017 · 0 comments · Fixed by #15233
Closed

COMPAT: datetime parsing with locale #15215

jreback opened this issue Jan 24, 2017 · 0 comments · Fixed by #15233
Labels
Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Jan 24, 2017

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)
@jreback jreback added Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype labels Jan 24, 2017
@jreback jreback added this to the 0.20.0 milestone Jan 24, 2017
jreback added a commit to jreback/pandas that referenced this issue Jan 26, 2017
jreback added a commit to jreback/pandas that referenced this issue Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant