@@ -661,7 +661,7 @@ def __repr__(self):
661661 from pandas .io .formats .printing import format_object_summary
662662
663663 template = (
664- u'< {class_name}> \n '
664+ u'{class_name}'
665665 u'{data}\n '
666666 u'Length: {length}, dtype: {dtype}'
667667 )
@@ -670,11 +670,17 @@ def __repr__(self):
670670 # any trailing newlines from format_object_summary
671671 data = format_object_summary (self , self ._formatter (), name = False ,
672672 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 ,
675675 length = len (self ),
676676 dtype = self .dtype )
677677
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+
678684 def _formatter (self , formatter = None ):
679685 # type: (Optional[ExtensionArrayFormatter]) -> Callable[[Any], str]
680686 """Formatting function for scalar values.
@@ -705,7 +711,12 @@ def _formatter(self, formatter=None):
705711 def _formatting_values (self ):
706712 # type: () -> np.ndarray
707713 # 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+ """
709720 return np .array (self )
710721
711722 # ------------------------------------------------------------------------
0 commit comments