Skip to content

Commit

Permalink
WIP: modified repr with some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dougbrn committed Jun 5, 2024
1 parent 0bb042a commit 098a0f2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/nested_pandas/nestedframe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def nested_columns(self) -> list:
nest_cols.append(column)
return nest_cols

def _repr_html_(self) -> str | None:
"""Override html representation"""

def my_style(df: NestedFrame, columns):

Check warning on line 58 in src/nested_pandas/nestedframe/core.py

View check run for this annotation

Codecov / codecov/patch

src/nested_pandas/nestedframe/core.py#L58

Added line #L58 was not covered by tests
"""Style generator for nested columns"""
style = {column: f"&ltcolumns={df[column].nest.fields}&gt" for column in columns}
return df.style.format(style)

Check warning on line 61 in src/nested_pandas/nestedframe/core.py

View check run for this annotation

Codecov / codecov/patch

src/nested_pandas/nestedframe/core.py#L60-L61

Added lines #L60 - L61 were not covered by tests

max_rows = pd.get_option("display.max_rows")
repr = super().pipe(my_style, self.nested_columns).to_html(max_rows=max_rows)
return repr

Check warning on line 65 in src/nested_pandas/nestedframe/core.py

View check run for this annotation

Codecov / codecov/patch

src/nested_pandas/nestedframe/core.py#L63-L65

Added lines #L63 - L65 were not covered by tests

def _is_known_hierarchical_column(self, colname) -> bool:
"""Determine whether a string is a known hierarchical column name"""
if "." in colname:
Expand Down

0 comments on commit 098a0f2

Please sign in to comment.