@@ -212,13 +212,13 @@ def _index_label_encoder(self):
212
212
if isinstance (obj .index , ABCMultiIndex ):
213
213
index_label = []
214
214
for i , name in enumerate (obj .index .names ):
215
- # if index_name is False, index name won't be displayed
215
+ # add empty string is name is None
216
216
if name is None :
217
217
name = ''
218
218
index_label .append (name )
219
219
else :
220
220
index_label = obj .index .name
221
- # if index_name is False, index name won't be displayed
221
+ # if no name, use empty string
222
222
if index_label is None :
223
223
index_label = ['' ]
224
224
else :
@@ -244,12 +244,11 @@ def _save_header(self):
244
244
has_aliases = isinstance (header , (tuple , list , np .ndarray ,
245
245
ABCIndexClass ))
246
246
if not (has_aliases or header ):
247
- # if index_label and header are False, nothing will display
247
+ # if index_label is False, nothing will display.
248
248
if index_label is False :
249
249
return
250
250
else :
251
- # if index_label is not None, index label will be displayed, if
252
- # index_label is None, a empty string will be given.
251
+ # based on index_label value, encoded labels are given
253
252
index_label , encoded_labels = self ._index_label_encoder ()
254
253
encoded_labels .extend (['' ] * len (obj .columns ))
255
254
writer .writerow (encoded_labels )
0 commit comments