update
This commit is contained in:
parent
50e60e38a9
commit
85490e8b59
4 changed files with 59 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +1,4 @@
|
|||
__pycache__/
|
||||
*.py[cod]
|
||||
venv/
|
||||
gc_wrapper/GC_DATA/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
try:
|
||||
from GC_Wrapper import GC_wrapper as GC
|
||||
from gc_wrapper.GC_Wrapper import GC_wrapper as GC
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
|
|
|||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
plotly
|
||||
pandas
|
||||
54
weight_trend.py
Normal file
54
weight_trend.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
WEIGHT_RANGE = [75, 85]
|
||||
|
||||
|
||||
def get_weight_measures():
|
||||
# query non-zero
|
||||
data = pd.DataFrame(GC.seasonMeasures(group="Body")).query("WEIGHTKG != 0.0")[
|
||||
["date", "WEIGHTKG"]
|
||||
]
|
||||
weight = data["WEIGHTKG"].to_numpy().flatten()
|
||||
weight_shifted = data["WEIGHTKG"].shift(periods=1)
|
||||
weight_shifted.loc[0] = 0.0
|
||||
weight_shifted = weight_shifted.to_numpy().flatten()
|
||||
change = weight - weight_shifted
|
||||
indices = np.argwhere(change != 0.0).flatten()
|
||||
weight = weight[indices]
|
||||
date = (
|
||||
data["date"].loc[indices] - pd.to_datetime("1900-01-01").date()
|
||||
).dt.days.to_numpy()
|
||||
return pd.DataFrame(
|
||||
np.hstack([date.reshape([-1, 1]), weight.reshape([-1, 1])]),
|
||||
columns=["date", "WEIGHTKG"],
|
||||
)
|
||||
|
||||
|
||||
weight_data = get_weight_measures()
|
||||
GC.setChart(
|
||||
type=GC.CHART_LINE,
|
||||
orientation=GC_VERTICAL,
|
||||
legpos=GC_ALIGN_RIGHT,
|
||||
stack=False,
|
||||
animate=True,
|
||||
)
|
||||
settings = {
|
||||
"symbol": GC_SYMBOL_CIRCLE,
|
||||
"line": GC_LINE_SOLID,
|
||||
"color": "red",
|
||||
"opacity": 100,
|
||||
"xaxis": "Date",
|
||||
"yaxis": "Weight",
|
||||
"size": 3,
|
||||
"opengl": False,
|
||||
}
|
||||
GC.addCurve(name="Weight", x=weight_data["date"], y=weight_data["WEIGHTKG"], **settings)
|
||||
GC.setAxis("Date", type=GC.AXIS_DATE)
|
||||
GC.setAxis(
|
||||
"Weight",
|
||||
type=GC.AXIS_CONTINUOUS,
|
||||
min=WEIGHT_RANGE[0],
|
||||
max=WEIGHT_RANGE[1],
|
||||
color="red",
|
||||
)
|
||||
Loading…
Reference in a new issue