Skip to content

Commit e9a290d

Browse files
committed
fixes failure with python2
1 parent 00a7ed8 commit e9a290d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/core/dtypes/cast.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from pandas._libs import lib, tslib, tslibs
88
from pandas._libs.tslibs import OutOfBoundsDatetime, Period, iNaT
9-
from pandas.compat import PY3, string_types, text_type
9+
from pandas.compat import PY3, string_types, text_type, to_str
1010

1111
from .common import (
1212
_INT64_DTYPE, _NS_DTYPE, _POSSIBLY_CAST_DTYPES, _TD_DTYPE, _string_dtypes,
@@ -1222,7 +1222,7 @@ def construct_1d_arraylike_from_scalar(value, length, dtype):
12221222
if isinstance(dtype, np.dtype) and dtype.kind in ("U", "S"):
12231223
subarr = np.empty(length, dtype=object)
12241224
if not isna(value):
1225-
value = text_type(value)
1225+
value = to_str(value)
12261226
else:
12271227
subarr = np.empty(length, dtype=dtype)
12281228
subarr.fill(value)

pandas/tests/series/test_constructors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def test_constructor_string_element_string_type(self):
151151

152152
def test_constructor_unicode_element_string_type(self):
153153
# GH 22477
154-
result = pd.Series(u'ѐ', index=[1], dtype=str)
155-
assert result.values.tolist() == [u'ѐ']
154+
result = pd.Series('ѐ', index=[1], dtype=str)
155+
assert result.values.tolist() == ['ѐ']
156156

157157
def test_constructor_dtype_str_na_values(self, string_dtype):
158158
# https://github.com/pandas-dev/pandas/issues/21083

0 commit comments

Comments
 (0)