Description
Code Sample, a copy-pastable example if possible
Some tests fail when parsing en_IL
locale in latest Ubuntu (e.g. TestSeriesDatetimeValues.test_dt_accessor_datetime_name_accessors
).
Ubuntu version
(pandas-dev) [pandas] lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic
The example of failed test message.
__________________________________________ TestSeriesDatetimeValues.test_dt_accessor_datetime_name_accessors[en_IL] ___________________________________________
self = <pandas.tests.series.test_datetime_values.TestSeriesDatetimeValues object at 0x7fcdf812f3c8>, time_locale = 'en_IL'
@pytest.mark.parametrize('time_locale', [
None] if tm.get_locales() is None else [None] + tm.get_locales())
def test_dt_accessor_datetime_name_accessors(self, time_locale):
# Test Monday -> Sunday and January -> December, in that sequence
if time_locale is None:
# If the time_locale is None, day-name and month_name should
# return the english attributes
expected_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday', 'Sunday']
expected_months = ['January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December']
else:
with tm.set_locale(time_locale, locale.LC_TIME):
expected_days = calendar.day_name[:]
expected_months = calendar.month_name[1:]
s = Series(DatetimeIndex(freq='D', start=datetime(1998, 1, 1),
periods=365))
english_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday', 'Sunday']
for day, name, eng_name in zip(range(4, 11),
expected_days,
english_days):
name = name.capitalize()
assert s.dt.weekday_name[day] == eng_name
> assert s.dt.day_name(locale=time_locale)[day] == name
pandas/tests/series/test_datetime_values.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/core/accessor.py:88: in f
return self._delegate_method(name, *args, **kwargs)
pandas/core/indexes/accessors.py:99: in _delegate_method
result = method(*args, **kwargs)
pandas/core/indexes/datetimes.py:2523: in day_name
locale=locale)
pandas/_libs/tslibs/fields.pyx:107: in pandas._libs.tslibs.fields.get_date_name_field
names = np.array(get_locale_names('f_weekday', locale),
pandas/_libs/tslibs/ccalendar.pyx:213: in pandas._libs.tslibs.ccalendar.get_locale_names
cpdef get_locale_names(object name_type, object locale=None):
pandas/_libs/tslibs/ccalendar.pyx:229: in pandas._libs.tslibs.ccalendar.get_locale_names
with set_locale(locale, LC_TIME):
pandas/_libs/tslibs/ccalendar.pyx:230: in pandas._libs.tslibs.ccalendar.get_locale_names
return getattr(LocaleTime(), name_type)
pandas/_libs/tslibs/strptime.pyx:396: in pandas._libs.tslibs.strptime.LocaleTime.__init__
self.lang = _getlang()
pandas/_libs/tslibs/strptime.pyx:354: in pandas._libs.tslibs.strptime._getlang
return locale.getlocale(locale.LC_TIME)
../../../anaconda3/envs/pandas-dev/lib/python3.6/locale.py:581: in getlocale
return _parse_localename(localename)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
localename = 'en_IL'
def _parse_localename(localename):
""" Parses the locale code for localename and returns the
result as tuple (language code, encoding).
The localename is normalized and passed through the locale
alias engine. A ValueError is raised in case the locale name
cannot be parsed.
The language code corresponds to RFC 1766. code and encoding
can be None in case the values cannot be determined or are
unknown to this implementation.
"""
code = normalize(localename)
if '@' in code:
# Deal with locale modifiers
code, modifier = code.split('@', 1)
if modifier == 'euro' and '.' not in code:
# Assume Latin-9 for @euro locales. This is bogus,
# since some systems may use other encodings for these
# locales. Also, we ignore other modifiers.
return code, 'iso-8859-15'
if '.' in code:
return tuple(code.split('.')[:2])
elif code == 'C':
return None, None
> raise ValueError('unknown locale: %s' % localename)
E ValueError: unknown locale: en_IL
../../../anaconda3/envs/pandas-dev/lib/python3.6/locale.py:490: ValueError
The result of tm.get_locales()
.
In [1]: import pandas.util.testing as tm
In [2]: tm.get_locales()
Out[2]:
['C',
'en_US.UTF-8',
'en_AG.UTF-8',
'en_AG.UTF-8',
'en_AU.UTF-8',
'en_BW.UTF-8',
'en_CA.UTF-8',
'en_DK.UTF-8',
'en_GB.UTF-8',
'en_HK.UTF-8',
'en_IE.UTF-8',
'en_IL',
'en_IL.utf8',
'en_IN.UTF-8',
'en_NG.UTF-8',
'en_NG.UTF-8',
'en_NZ.UTF-8',
'en_PH.UTF-8',
'en_SG.UTF-8',
'en_US.UTF-8',
'en_ZA.UTF-8',
'en_ZM.UTF-8',
'en_ZM.UTF-8',
'ja_JP.UTF-8',
'C',
'']
Problem description
Seems that this is the locale which does not have the encoding.
https://ubuntuforums.org/showthread.php?t=2358452
Expected Output
No test failure.
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: ef019fa
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-20-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.23.0rc2+9.gef019faa0.dirty
pytest: 3.5.1
pip: 10.0.1
setuptools: 39.1.0
Cython: 0.28.2
numpy: 1.14.2
scipy: None
pyarrow: None
xarray: None
IPython: 6.3.1
sphinx: 1.7.4
patsy: None
dateutil: 2.7.2
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None