ENH: Don't add rowspan/colspan if it's 1. · pandas-dev/pandas@f65a641 (original) (raw)

`@@ -141,21 +141,18 @@ def test_empty_index_name_doesnt_display(self):

`

141

141

`'type': 'th',

`

142

142

`'value': 'A',

`

143

143

`'is_visible': True,

`

144

``

`-

'attributes': ["colspan=1"],

`

145

144

` },

`

146

145

` {'class': 'col_heading level0 col1',

`

147

146

`'display_value': 'B',

`

148

147

`'type': 'th',

`

149

148

`'value': 'B',

`

150

149

`'is_visible': True,

`

151

``

`-

'attributes': ["colspan=1"],

`

152

150

` },

`

153

151

` {'class': 'col_heading level0 col2',

`

154

152

`'display_value': 'C',

`

155

153

`'type': 'th',

`

156

154

`'value': 'C',

`

157

155

`'is_visible': True,

`

158

``

`-

'attributes': ["colspan=1"],

`

159

156

` }]]

`

160

157

``

161

158

`self.assertEqual(result['head'], expected)

`

`@@ -168,11 +165,9 @@ def test_index_name(self):

`

168

165

`expected = [[{'class': 'blank level0', 'type': 'th', 'value': '',

`

169

166

`'display_value': '', 'is_visible': True},

`

170

167

` {'class': 'col_heading level0 col0', 'type': 'th',

`

171

``

`-

'value': 'B', 'display_value': 'B',

`

172

``

`-

'is_visible': True, 'attributes': ['colspan=1']},

`

``

168

`+

'value': 'B', 'display_value': 'B', 'is_visible': True},

`

173

169

` {'class': 'col_heading level0 col1', 'type': 'th',

`

174

``

`-

'value': 'C', 'display_value': 'C',

`

175

``

`-

'is_visible': True, 'attributes': ['colspan=1']}],

`

``

170

`+

'value': 'C', 'display_value': 'C', 'is_visible': True}],

`

176

171

` [{'class': 'index_name level0', 'type': 'th',

`

177

172

`'value': 'A'},

`

178

173

` {'class': 'blank', 'type': 'th', 'value': ''},

`

`@@ -191,9 +186,7 @@ def test_multiindex_name(self):

`

191

186

` {'class': 'blank level0', 'type': 'th', 'value': '',

`

192

187

`'display_value': '', 'is_visible': True},

`

193

188

` {'class': 'col_heading level0 col0', 'type': 'th',

`

194

``

`-

'value': 'C', 'display_value': 'C',

`

195

``

`-

'is_visible': True, 'attributes': ['colspan=1'],

`

196

``

`-

}],

`

``

189

`+

'value': 'C', 'display_value': 'C', 'is_visible': True}],

`

197

190

` [{'class': 'index_name level0', 'type': 'th',

`

198

191

`'value': 'A'},

`

199

192

` {'class': 'index_name level1', 'type': 'th',

`

`@@ -618,16 +611,14 @@ def test_mi_sparse(self):

`

618

611

`body_1 = result['body'][0][1]

`

619

612

`expected_1 = {

`

620

613

`"value": 0, "display_value": 0, "is_visible": True,

`

621

``

`-

"type": "th", "attributes": ["rowspan=1"],

`

622

``

`-

"class": "row_heading level1 row0",

`

``

614

`+

"type": "th", "class": "row_heading level1 row0",

`

623

615

` }

`

624

616

`tm.assert_dict_equal(body_1, expected_1)

`

625

617

``

626

618

`body_10 = result['body'][1][0]

`

627

619

`expected_10 = {

`

628

620

`"value": 'a', "display_value": 'a', "is_visible": False,

`

629

``

`-

"type": "th", "attributes": ["rowspan=1"],

`

630

``

`-

"class": "row_heading level0 row1",

`

``

621

`+

"type": "th", "class": "row_heading level0 row1",

`

631

622

` }

`

632

623

`tm.assert_dict_equal(body_10, expected_10)

`

633

624

``

`@@ -637,9 +628,8 @@ def test_mi_sparse(self):

`

637

628

`'is_visible': True, "display_value": ''},

`

638

629

` {'type': 'th', 'class': 'blank level0', 'value': '',

`

639

630

`'is_visible': True, 'display_value': ''},

`

640

``

`-

{'attributes': ['colspan=1'], 'class': 'col_heading level0 col0',

`

641

``

`-

'is_visible': True, 'type': 'th', 'value': 'A',

`

642

``

`-

'display_value': 'A'}]

`

``

631

`+

{'type': 'th', 'class': 'col_heading level0 col0', 'value': 'A',

`

``

632

`+

'is_visible': True, 'display_value': 'A'}]

`

643

633

`self.assertEqual(head, expected)

`

644

634

``

645

635

`def test_mi_sparse_disabled(self):

`

`@@ -650,7 +640,7 @@ def test_mi_sparse_disabled(self):

`

650

640

`result = df.style._translate()

`

651

641

`body = result['body']

`

652

642

`for row in body:

`

653

``

`-

self.assertEqual(row[0]['attributes'], ['rowspan=1'])

`

``

643

`+

assert 'attributes' not in row[0]

`

654

644

``

655

645

`def test_mi_sparse_index_names(self):

`

656

646

`df = pd.DataFrame({'A': [1, 2]}, index=pd.MultiIndex.from_arrays(

`

`@@ -686,28 +676,24 @@ def test_mi_sparse_column_names(self):

`

686

676

`'type': 'th', 'is_visible': True},

`

687

677

` {'class': 'index_name level1', 'value': 'col_1',

`

688

678

`'display_value': 'col_1', 'is_visible': True, 'type': 'th'},

`

689

``

`-

{'attributes': ['colspan=1'],

`

690

``

`-

'class': 'col_heading level1 col0',

`

``

679

`+

{'class': 'col_heading level1 col0',

`

691

680

`'display_value': 1,

`

692

681

`'is_visible': True,

`

693

682

`'type': 'th',

`

694

683

`'value': 1},

`

695

``

`-

{'attributes': ['colspan=1'],

`

696

``

`-

'class': 'col_heading level1 col1',

`

``

684

`+

{'class': 'col_heading level1 col1',

`

697

685

`'display_value': 0,

`

698

686

`'is_visible': True,

`

699

687

`'type': 'th',

`

700

688

`'value': 0},

`

701

689

``

702

``

`-

{'attributes': ['colspan=1'],

`

703

``

`-

'class': 'col_heading level1 col2',

`

``

690

`+

{'class': 'col_heading level1 col2',

`

704

691

`'display_value': 1,

`

705

692

`'is_visible': True,

`

706

693

`'type': 'th',

`

707

694

`'value': 1},

`

708

695

``

709

``

`-

{'attributes': ['colspan=1'],

`

710

``

`-

'class': 'col_heading level1 col3',

`

``

696

`+

{'class': 'col_heading level1 col3',

`

711

697

`'display_value': 0,

`

712

698

`'is_visible': True,

`

713

699

`'type': 'th',

`