@@ -661,7 +661,7 @@ def __repr__(self):
661
661
from pandas .io .formats .printing import format_object_summary
662
662
663
663
template = (
664
- u'< {class_name}> \n '
664
+ u'{class_name}'
665
665
u'{data}\n '
666
666
u'Length: {length}, dtype: {dtype}'
667
667
)
@@ -670,11 +670,17 @@ def __repr__(self):
670
670
# any trailing newlines from format_object_summary
671
671
data = format_object_summary (self , self ._formatter (), name = False ,
672
672
trailing_comma = False ).rstrip ()
673
- name = self .__class__ .__name__
674
- return template .format (class_name = name , data = data ,
673
+ class_name = u'<{}> \n ' . format ( self .__class__ .__name__ )
674
+ return template .format (class_name = class_name , data = data ,
675
675
length = len (self ),
676
676
dtype = self .dtype )
677
677
678
+ def __bytes__ (self ):
679
+ from pandas .core .config import get_option
680
+
681
+ encoding = get_option ("display.encoding" )
682
+ return str (self ).encode (encoding , 'replace' )
683
+
678
684
def _formatter (self , formatter = None ):
679
685
# type: (Optional[ExtensionArrayFormatter]) -> Callable[[Any], str]
680
686
"""Formatting function for scalar values.
@@ -705,7 +711,12 @@ def _formatter(self, formatter=None):
705
711
def _formatting_values (self ):
706
712
# type: () -> np.ndarray
707
713
# At the moment, this has to be an array since we use result.dtype
708
- """An array of values to be printed in, e.g. the Series repr"""
714
+ """An array of values to be printed in, e.g. the Series repr
715
+
716
+ .. deprecated:: 0.24.0
717
+
718
+ Use :meth:`ExtensionArray._formatter` instead.
719
+ """
709
720
return np .array (self )
710
721
711
722
# ------------------------------------------------------------------------
0 commit comments