File tree 2 files changed +15
-19
lines changed
2 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -665,26 +665,12 @@ def copy(self, deep=False):
665
665
# Printing
666
666
# ------------------------------------------------------------------------
667
667
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 ):
682
668
from pandas .io .formats .printing import format_object_summary
683
669
684
670
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}'
688
674
)
689
675
# the short repr has no trailing newline, while the truncated
690
676
# repr does. So we include a newline in our template, and strip
@@ -696,6 +682,18 @@ def __repr__(self):
696
682
length = len (self ),
697
683
dtype = self .dtype )
698
684
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
+
699
697
def _formatter (self , formatter = None ):
700
698
# type: (Optional[ExtensionArrayFormatter]) -> Callable[[Any], str]
701
699
"""Formatting function for scalar values.
Original file line number Diff line number Diff line change @@ -1990,8 +1990,6 @@ def __unicode__(self):
1990
1990
1991
1991
return result
1992
1992
1993
- __repr__ = __unicode__
1994
-
1995
1993
def _maybe_coerce_indexer (self , indexer ):
1996
1994
""" return an indexer coerced to the codes dtype """
1997
1995
if isinstance (indexer , np .ndarray ) and indexer .dtype .kind == 'i' :
You can’t perform that action at this time.
0 commit comments