diff --git a/my/body/__init__.py b/my/body/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/my/body/sleep/common.py b/my/body/sleep/common.py new file mode 100644 index 0000000..81879fe --- /dev/null +++ b/my/body/sleep/common.py @@ -0,0 +1,17 @@ +from ...core import stat, Stats +from ...core.pandas import DataFrameT, check_dataframe as cdf + + +class Combine: + def __init__(self, modules) -> None: + self.modules = modules + + @cdf + def dataframe(self) -> DataFrameT: + import pandas as pd # type: ignore + # todo include 'source'? + df = pd.concat([m.dataframe() for m in self.modules]) + return df + + def stats(self) -> Stats: + return stat(self.dataframe) diff --git a/my/body/sleep/main.py b/my/body/sleep/main.py new file mode 100644 index 0000000..29b12a7 --- /dev/null +++ b/my/body/sleep/main.py @@ -0,0 +1,11 @@ +from ... import jawbone +from ... import emfit + +from .common import Combine +_combined = Combine([ + jawbone, + emfit, +]) + +dataframe = _combined.dataframe +stats = _combined.stats diff --git a/my/emfit/__init__.py b/my/emfit/__init__.py index 53999b7..acf302c 100755 --- a/my/emfit/__init__.py +++ b/my/emfit/__init__.py @@ -133,7 +133,7 @@ def dataframe() -> DataFrameT: import pandas # type: ignore return pandas.DataFrame(dicts) -# TODO add dataframe support to stat() + from ..core import stat, Stats def stats() -> Stats: return stat(pre_dataframe) diff --git a/my/jawbone/__init__.py b/my/jawbone/__init__.py index 7ea9ad6..c21d455 100755 --- a/my/jawbone/__init__.py +++ b/my/jawbone/__init__.py @@ -147,7 +147,6 @@ def dataframe(): # TODO tz is in sleeps json -# TODO add dataframe support to stat() def stats(): from ..core import stat return stat(pre_dataframe)