Skip to content

Commit ff0c998

Browse files
committed
fixup
1 parent 5b07906 commit ff0c998

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

pandas/core/arrays/base.py

+15-17
Original file line numberDiff line numberDiff line change
@@ -665,26 +665,12 @@ def copy(self, deep=False):
665665
# Printing
666666
# ------------------------------------------------------------------------
667667
def __unicode__(self):
668-
result = str(self)
669-
if compat.PY2:
670-
encoding = get_option("display.encoding")
671-
result = result.decode(encoding)
672-
return result
673-
674-
def __bytes__(self):
675-
result = str(self)
676-
if compat.PY3:
677-
encoding = get_option("display.encoding")
678-
result = result.encode(encoding)
679-
return result
680-
681-
def __repr__(self):
682668
from pandas.io.formats.printing import format_object_summary
683669

684670
template = (
685-
'<{class_name}>\n'
686-
'{data}\n'
687-
'Length: {length}, dtype: {dtype}'
671+
u'<{class_name}>\n'
672+
u'{data}\n'
673+
u'Length: {length}, dtype: {dtype}'
688674
)
689675
# the short repr has no trailing newline, while the truncated
690676
# repr does. So we include a newline in our template, and strip
@@ -696,6 +682,18 @@ def __repr__(self):
696682
length=len(self),
697683
dtype=self.dtype)
698684

685+
def __str__(self):
686+
if compat.PY3:
687+
return self.__unicode__()
688+
return self.__bytes__()
689+
690+
def __bytes__(self):
691+
encoding = get_option("display.encoding")
692+
return self.__unicode__().encode(encoding, 'replace')
693+
694+
def __repr__(self):
695+
return str(self)
696+
699697
def _formatter(self, formatter=None):
700698
# type: (Optional[ExtensionArrayFormatter]) -> Callable[[Any], str]
701699
"""Formatting function for scalar values.

pandas/core/arrays/categorical.py

-2
Original file line numberDiff line numberDiff line change
@@ -1990,8 +1990,6 @@ def __unicode__(self):
19901990

19911991
return result
19921992

1993-
__repr__ = __unicode__
1994-
19951993
def _maybe_coerce_indexer(self, indexer):
19961994
""" return an indexer coerced to the codes dtype """
19971995
if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i':

0 commit comments

Comments
 (0)