Skip to content

Commit

Permalink
feat!: Refactor Report into Report and DefaultReport. (#47)
Browse files Browse the repository at this point in the history
Resolves #45
  • Loading branch information
mbelak-dtml authored Aug 7, 2023
1 parent 7c6ab67 commit d664e6c
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 136 deletions.
4 changes: 2 additions & 2 deletions api-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dataset.head()
```

```python
report = edvart.Report(
report = edvart.DefaultReport(
dataset,
verbosity=0,
columns_overview=['Name', 'Survived'],
Expand Down Expand Up @@ -69,7 +69,7 @@ dataset_ts = edvart.example_datasets.dataset_global_temp()
```

```python
report_ts = edvart.TimeseriesReport(
report_ts = edvart.DefaultTimeseriesReport(
dataset_ts,
# Monthly data -> analyze yearly seasonality
sampling_rate=12,
Expand Down
24 changes: 14 additions & 10 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Report class
------------

The most important class of the package :py:class:`~edvart.report.Report`.
This class allows you to specify :ref:`verbosity <verbosity>` or specify which columns should be used.
The report consists of sections, which can be added via methods of the `Report` class.
The report is empty by default.
The class :py:class:`~edvart.report.DefaultReport` is a subclass of `Report`,
which contains a default set of sections.

With created instance of `Report` you can:

Expand Down Expand Up @@ -114,17 +117,18 @@ or modifying sections settings.

Selection of sections
~~~~~~~~~~~~~~~~~~~~~

If you want to use only a subset of sections you have to set
`use_default_sections` parameter of report to `False` and then you can add your own sections.
You can add sections using methods `add_*` of the `Report` class.

.. code-block:: python
# Shows only univariate analysis
# Shows only univariate and bivariate analysis
import edvart
df = edvart.example_datasets.dataset_titanic()
report = edvart.Report(df, use_default_sections=False)
report.add_univariate_analysis()
report = (
edvart.Report(df)
.add_univariate_analysis()
.add_bivariate_analysis()
)
Sections configuration
Expand All @@ -141,7 +145,7 @@ Or you can set section verbosity (described later).
import edvart
df = edvart.example_datasets.dataset_titanic()
report = edvart.Report(df, columns_overview=["Name", "Survived"], use_default_sections=False)
report = edvart.Report(df)
report.add_overview(omit_columns=["PassengerId"]).add_univariate_analysis(
use_columns=["Name", "Sex", "Age"]
Expand Down Expand Up @@ -176,7 +180,7 @@ Examples:
import edvart
df = edvart.example_datasets.dataset_titanic()
edvart.Report(df, verbosity=1).export_notebook("test-export.ipynb")
edvart.DefaultReport(df, verbosity=1).export_notebook("test-export.ipynb")
.. code-block:: python
Expand All @@ -185,4 +189,4 @@ Examples:
import edvart
df = edvart.example_datasets.dataset_titanic()
edvart.Report(df, verbosity=1, verbosity_univariate_analysis=2).export_notebook("test-export.ipynb")
edvart.DefaultReport(df, verbosity=1, verbosity_univariate_analysis=2).export_notebook("test-export.ipynb")
6 changes: 3 additions & 3 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Getting started
import edvart
df = edvart.example_datasets.dataset_titanic()
edvart.Report(df).show()
edvart.DefaultReport(df).show()
2. Generate report notebook

.. code-block:: python
import edvart
df = edvart.example_datasets.dataset_titanic()
report = edvart.Report(df)
report = edvart.DefaultReport(df)
report.export_notebook("titanic_report.ipynb")
You can modify the generated notebook if you want to modify some settings.
Expand All @@ -28,7 +28,7 @@ For more advanced usage of edvart, please read the documentation section
import edvart
df = edvart.example_datasets.dataset_titanic()
report = edvart.Report(df)
report = edvart.DefaultReport(df)
report.export_html(
html_filepath="titanic_report.html",
dataset_name="Titanic",
Expand Down
1 change: 1 addition & 0 deletions edvart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from importlib.metadata import PackageNotFoundError, version

from edvart import example_datasets
from edvart.report import DefaultReport, DefaultTimeseriesReport
from edvart.report import Report
from edvart.report import Report as create_report
from edvart.report import TimeseriesReport
Expand Down
Loading

0 comments on commit d664e6c

Please sign in to comment.