@@ -49,7 +49,7 @@ class DataFrameFormatter(object):
49
49
def __init__ (self , frame , buf = None , columns = None , col_space = None ,
50
50
header = True , index = True , na_rep = 'NaN' , formatters = None ,
51
51
justify = 'left' , float_format = None , sparsify = True ,
52
- index_names = True ):
52
+ index_names = True , ** kwds ):
53
53
self .frame = frame
54
54
self .buf = buf if buf is not None else StringIO ()
55
55
self .show_index_names = index_names
@@ -62,6 +62,8 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
62
62
self .index = index
63
63
self .justify = justify
64
64
65
+ self .kwds = kwds
66
+
65
67
if columns is not None :
66
68
self .columns = _ensure_index (columns )
67
69
else :
@@ -217,13 +219,22 @@ def _column_header():
217
219
218
220
write (buf , '<tbody>' , indent )
219
221
222
+ _bold_row = self .kwds .get ('bold_rows' , False )
223
+ def _maybe_bold_row (x ):
224
+ temp = '<strong>%s</strong>'
225
+ if _bold_row :
226
+ return ([temp % y for y in x ] if isinstance (x , tuple )
227
+ else temp % x )
228
+ else :
229
+ return x
230
+
220
231
# write values
221
232
for i in range (len (frame )):
222
233
row = []
223
234
if isinstance (frame .index , MultiIndex ):
224
- row .extend (frame .index [i ])
235
+ row .extend (_maybe_bold_row ( frame .index [i ]) )
225
236
else :
226
- row .append (frame .index [i ])
237
+ row .append (_maybe_bold_row ( frame .index [i ]) )
227
238
for column in frame .columns :
228
239
row .append (self ._format_col (column , i ))
229
240
write_tr (buf , row , indent , indent_delta )
0 commit comments