Skip to content

Commit 8a13aa9

Browse files
committed
TST: Test rendering of 2 empty-ish DataFrames (pandas-dev#15953)
DataFrame with an index but no column, and one with a column but no index. Add entry to whatsnew.
1 parent 8a4e471 commit 8a13aa9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

doc/source/whatsnew/v0.20.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ I/O
5454
^^^
5555

5656
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`)
57+
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`)
5758

5859

5960
Plotting

pandas/tests/io/formats/test_style.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ def test_render(self):
103103
s.render()
104104
# it worked?
105105

106-
def test_render_empty_df(self):
106+
def test_render_empty_dfs(self):
107107
empty_df = DataFrame()
108108
es = Styler(empty_df)
109109
es.render()
110-
# It didn't raise IndexError?
110+
# An index but no columns
111+
DataFrame(columns=['a']).style.render()
112+
# A column but no index
113+
DataFrame(index=['a']).style.render()
114+
# No IndexError raised?
111115

112116
def test_render_double(self):
113117
df = pd.DataFrame({"A": [0, 1]})

0 commit comments

Comments
 (0)