@@ -25,24 +25,29 @@ def _pd_rich_repr(self, console, console_options):
2525 show_dimensions = get_option ("display.show_dimension" ),
2626 )
2727 sformatter = StringFormatter (formatter )
28- string_cols = sformatter ._get_strcols ()
2928
30- table = Table (box = SIMPLE , row_styles = ["dim" , "" ])
31- if formatter .has_index_names :
32- for i , c in enumerate (string_cols ):
33- table .add_column ("\n " .join (c [:2 ]), style = "bold" if i == 0 else None , justify = "left" if i == 0 else "right" )
34- start_row = 2
29+ if self .empty :
30+ yield sformatter ._empty_info_line .replace ('[' , '\[' )
31+
3532 else :
36- for i , c in enumerate (string_cols ):
37- table .add_column (c [0 ], style = "bold" if i == 0 else None , justify = "left" if i == 0 else "right" )
38- start_row = 1
39- for i in range (start_row , len (string_cols [0 ])):
40- table .add_row (* [c [i ] for c in string_cols ])
41- if get_option ("display.expand_frame_repr" ):
42- console_options = console_options .update (max_width = 256 )
43- yield from table .__rich_console__ (console , console_options )
44- if formatter .should_show_dimensions :
45- yield formatter .dimensions_info .strip ()
33+ string_cols = sformatter ._get_strcols ()
34+
35+ table = Table (box = SIMPLE , row_styles = ["dim" , "" ])
36+ if formatter .has_index_names :
37+ for i , c in enumerate (string_cols ):
38+ table .add_column ("\n " .join (c [:2 ]), style = "bold" if i == 0 else None , justify = "left" if i == 0 else "right" )
39+ start_row = 2
40+ else :
41+ for i , c in enumerate (string_cols ):
42+ table .add_column (c [0 ], style = "bold" if i == 0 else None , justify = "left" if i == 0 else "right" )
43+ start_row = 1
44+ for i in range (start_row , len (string_cols [0 ])):
45+ table .add_row (* [c [i ] for c in string_cols ])
46+ if get_option ("display.expand_frame_repr" ):
47+ console_options = console_options .update (max_width = 256 )
48+ yield from table .__rich_console__ (console , console_options )
49+ if formatter .should_show_dimensions :
50+ yield formatter .dimensions_info .strip ()
4651
4752
4853_DataFrame .__rich_console__ = _pd_rich_repr
0 commit comments