Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add parameter BoxplotsOverTime.group_function_imports #157

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class BoxplotsOverTime(Section):
function must be assigned an identifier.
To pass a lambda, simply assign it to a variable and pass the variable.
If None is passed, a default grouping will be selected (see `default_nunique_max`).
grouping_function_imports: List[str], optional
Additional imports required for the grouping function.
grouping_name : str, optional
Name of grouping, will be displayed as title of the horizontal axis.
default_nunique_max : int (default = 80)
Expand All @@ -49,10 +51,12 @@ def __init__(
verbosity: Verbosity = Verbosity.LOW,
columns: Optional[List[str]] = None,
grouping_function: Callable[[Any], str] = None,
grouping_function_imports: Optional[List[str]] = None,
grouping_name: Optional[str] = None,
default_nunique_max: int = 80,
):
self.grouping_function = grouping_function
self.grouping_function_imports = grouping_function_imports
self.grouping_name = grouping_name
self.default_nunique_max = default_nunique_max
super().__init__(verbosity, columns)
Expand All @@ -71,17 +75,21 @@ def required_imports(self) -> List[str]:
e.g. ["import pandas as pd", "import numpy as np"].
"""
if self.verbosity <= Verbosity.MEDIUM:
return [
imports = [
"from edvart.report_sections.timeseries_analysis.boxplots_over_time"
" import show_boxplots_over_time"
]
return [
"from datetime import datetime",
"import matplotlib.pyplot as plt",
"import seaborn as sns",
"from IPython.display import display, Markdown",
"from edvart.data_types import is_numeric",
]
else:
imports = [
"from datetime import datetime",
"import matplotlib.pyplot as plt",
"import seaborn as sns",
"from IPython.display import display, Markdown",
"from edvart.data_types import is_numeric",
]
if self.grouping_function_imports is not None:
imports.extend(self.grouping_function_imports)
return imports

def add_cells(self, cells: List[Dict[str, Any]], df: pd.DataFrame) -> None:
"""Adds cells to the list of cells.
Expand Down