This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3575ce
commit 06d67fe
Showing
5 changed files
with
28 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
"""Disable output of warnings.""" | ||
|
||
from __future__ import annotations | ||
|
||
import logging | ||
import warnings | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,29 @@ | ||
"""Display column descriptions.""" | ||
|
||
import pandas as pd | ||
from IPython.core.display_functions import DisplayHandle | ||
from IPython.display import display | ||
from __future__ import annotations | ||
|
||
from IPython.core.display import DisplayObject | ||
from IPython.display import Markdown | ||
from safeds.data.tabular.containers import Table | ||
|
||
|
||
def display_column_descriptions(column_descriptions: Table) -> DisplayHandle: | ||
def display_column_descriptions(column_descriptions: Table) -> DisplayObject: | ||
""" | ||
Display a Table containing the column descriptions. | ||
Parameters | ||
---------- | ||
column_descriptions : Table | ||
column_descriptions: | ||
The column descriptions. | ||
Returns | ||
------- | ||
DisplayHandle | ||
The display handle. | ||
display_object: | ||
The display object. | ||
""" | ||
# Remember the current value of the max_colwidth option | ||
max_colwidth = pd.get_option("max_colwidth") | ||
|
||
# Don't cut off the column descriptions | ||
pd.set_option("max_colwidth", None) | ||
|
||
# Create a DisplayHandle that displays the column descriptions nicely | ||
styler = ( | ||
column_descriptions._data.style.relabel_index(["Name", "Description"], axis="columns") | ||
.hide(axis="index") | ||
.set_properties( | ||
**{ | ||
"text-align": "left", | ||
"white-space": "pre-wrap", | ||
}, | ||
) | ||
) | ||
result = display(styler) | ||
|
||
# Restore the max_colwidth option | ||
pd.set_option("max_colwidth", max_colwidth) | ||
|
||
return result | ||
result = "" | ||
|
||
for name, description in column_descriptions._data_frame.iter_rows(): | ||
result += f"- **{name}:** {description}\n" | ||
|
||
return Markdown(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters