Skip to content

Commit d12ec6e

Browse files
authored
Merge pull request #209 from lincc-frameworks/html_repr_bugs
Double Header: fix max_rows & empty chunk bugs
2 parents 495b047 + 88e5a4e commit d12ec6e

File tree

1 file changed

+10
-1
lines changed
  • src/nested_pandas/nestedframe

1 file changed

+10
-1
lines changed

src/nested_pandas/nestedframe/core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ def _repr_html_(self) -> str | None:
291291
# Nested Column Formatting
292292
# first cell shows the nested df header and a preview row
293293
def repack_first_cell(chunk):
294+
# If the chunk is None, just return None
295+
# Means that the column labels will not be shown
296+
if chunk is None:
297+
return None
294298
# Render header separately to keep data aligned
295299
output = chunk.head(0).to_html(
296300
max_rows=0, max_cols=5, show_dimensions=False, index=False, header=True
@@ -301,6 +305,9 @@ def repack_first_cell(chunk):
301305

302306
# remaining cells show only a preview row
303307
def repack_row(chunk):
308+
# If the chunk is None, just return None
309+
if chunk is None:
310+
return None
304311
return chunk.to_html(max_rows=1, max_cols=5, show_dimensions=True, index=False, header=False)
305312

306313
# Apply repacking to all nested columns
@@ -312,7 +319,9 @@ def repack_row(chunk):
312319
)
313320

314321
# Recover some truncation formatting, limited to head truncation
315-
if repr.data.shape[0] > pd.get_option("display.max_rows"):
322+
if pd.get_option("display.max_rows") is None:
323+
return repr.to_html(max_rows=0)
324+
elif repr.data.shape[0] > pd.get_option("display.max_rows"):
316325
html_repr = repr.to_html(max_rows=pd.get_option("display.min_rows"))
317326
else:
318327
# when under the max_rows threshold, display all rows (behavior of 0 here)

0 commit comments

Comments
 (0)