add my.body.sleep, combine together emfit/jawbone
This commit is contained in:
parent
e8e4994c02
commit
725597de97
5 changed files with 29 additions and 2 deletions
17
my/body/sleep/common.py
Normal file
17
my/body/sleep/common.py
Normal file
|
@ -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)
|
11
my/body/sleep/main.py
Normal file
11
my/body/sleep/main.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from ... import jawbone
|
||||||
|
from ... import emfit
|
||||||
|
|
||||||
|
from .common import Combine
|
||||||
|
_combined = Combine([
|
||||||
|
jawbone,
|
||||||
|
emfit,
|
||||||
|
])
|
||||||
|
|
||||||
|
dataframe = _combined.dataframe
|
||||||
|
stats = _combined.stats
|
|
@ -133,7 +133,7 @@ def dataframe() -> DataFrameT:
|
||||||
import pandas # type: ignore
|
import pandas # type: ignore
|
||||||
return pandas.DataFrame(dicts)
|
return pandas.DataFrame(dicts)
|
||||||
|
|
||||||
# TODO add dataframe support to stat()
|
|
||||||
from ..core import stat, Stats
|
from ..core import stat, Stats
|
||||||
def stats() -> Stats:
|
def stats() -> Stats:
|
||||||
return stat(pre_dataframe)
|
return stat(pre_dataframe)
|
||||||
|
|
|
@ -147,7 +147,6 @@ def dataframe():
|
||||||
# TODO tz is in sleeps json
|
# TODO tz is in sleeps json
|
||||||
|
|
||||||
|
|
||||||
# TODO add dataframe support to stat()
|
|
||||||
def stats():
|
def stats():
|
||||||
from ..core import stat
|
from ..core import stat
|
||||||
return stat(pre_dataframe)
|
return stat(pre_dataframe)
|
||||||
|
|
Loading…
Add table
Reference in a new issue