@@ -238,24 +238,25 @@ def format_attr(pair):
238
238
"class" : " " .join (cs ),
239
239
"is_visible" : True })
240
240
241
- for c , value in enumerate (clabels [r ]):
242
- cs = [COL_HEADING_CLASS , "level%s" % r , "col%s" % c ]
243
- cs .extend (cell_context .get (
244
- "col_headings" , {}).get (r , {}).get (c , []))
245
- es = {
246
- "type" : "th" ,
247
- "value" : value ,
248
- "display_value" : value ,
249
- "class" : " " .join (cs ),
250
- "is_visible" : _is_visible (c , r , col_lengths ),
251
- }
252
- colspan = col_lengths .get ((r , c ), 0 )
253
- if colspan > 1 :
254
- es ["attributes" ] = [
255
- format_attr ({"key" : "colspan" , "value" : colspan })
256
- ]
257
- row_es .append (es )
258
- head .append (row_es )
241
+ if clabels :
242
+ for c , value in enumerate (clabels [r ]):
243
+ cs = [COL_HEADING_CLASS , "level%s" % r , "col%s" % c ]
244
+ cs .extend (cell_context .get (
245
+ "col_headings" , {}).get (r , {}).get (c , []))
246
+ es = {
247
+ "type" : "th" ,
248
+ "value" : value ,
249
+ "display_value" : value ,
250
+ "class" : " " .join (cs ),
251
+ "is_visible" : _is_visible (c , r , col_lengths ),
252
+ }
253
+ colspan = col_lengths .get ((r , c ), 0 )
254
+ if colspan > 1 :
255
+ es ["attributes" ] = [
256
+ format_attr ({"key" : "colspan" , "value" : colspan })
257
+ ]
258
+ row_es .append (es )
259
+ head .append (row_es )
259
260
260
261
if self .data .index .names and not all (x is None
261
262
for x in self .data .index .names ):
0 commit comments