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

get dataset included in autodoc #94

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions causalpy/data/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
}


def get_data_home():
def _get_data_home() -> pathlib.PosixPath:
"""Return the path of the data directory"""
return pathlib.Path(cp.__file__).parents[1] / "causalpy" / "data"


def load_data(dataset: str = None):
def load_data(dataset: str = None) -> pd.DataFrame:
"""Loads the requested dataset and returns a pandas DataFrame.

:param dataset: The desired dataset to load
"""

if dataset in DATASETS:

data_dir = get_data_home()
data_dir = _get_data_home()
datafile = DATASETS[dataset]
file_path = data_dir / datafile["filename"]
return pd.read_csv(file_path)
Expand Down
9 changes: 9 additions & 0 deletions docs/api_datasets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`causalpy.data.datasets`
=============================

.. toctree::
:maxdepth: 1

.. automodule:: causalpy.data.datasets
:members:
:undoc-members:
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Documentation outline
api_pymc_experiments
api_pymc_models
api_plot_utils
api_datasets


Index
Expand Down