Created
November 1, 2018 20:42
-
-
Save vanous/592b0a12fb2596f6c0d960909fb9c9d3 to your computer and use it in GitHub Desktop.
gadgedbridge simple data exploration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import matplotlib.pyplot as plt | |
import datetime | |
import numpy as np | |
conn = sqlite3.connect('Gadgetbridge') | |
c = conn.cursor() | |
a=c.execute("select strftime('%Y.%m.%d', datetime(timestamp, 'unixepoch')) as d,sum(STEPS) from MI_BAND_ACTIVITY_SAMPLE group by d").fetchall() | |
b={x[0]:x[1] for x in a} | |
fig, ax = plt.subplots() | |
plt.bar( | |
np.arange(len(b)), | |
list(b.values()), | |
0.3, | |
tick_label=list(b.keys()), | |
label="steps", | |
color="#ff7f0e", | |
) | |
plt.legend() | |
plt.tight_layout() | |
plt.xticks(rotation=60) | |
plt.show() | |
c.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
that results in:
One can also group by say week:
a=c.execute("select strftime('%W', datetime(timestamp, 'unixepoch')) as d,sum(STEPS) from MI_BAND_ACTIVITY_SAMPLE group by d").fetchall()