Skip to content

Commit

Permalink
get dataset included in autodoc
Browse files Browse the repository at this point in the history
  • Loading branch information
drbenvincent committed Nov 25, 2022
1 parent 988ac05 commit 856febe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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

0 comments on commit 856febe

Please sign in to comment.