Skip to content

Instantly share code, notes, and snippets.

@vanous
Created November 1, 2018 20:42
Show Gist options
  • Save vanous/592b0a12fb2596f6c0d960909fb9c9d3 to your computer and use it in GitHub Desktop.
Save vanous/592b0a12fb2596f6c0d960909fb9c9d3 to your computer and use it in GitHub Desktop.
gadgedbridge simple data exploration
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()
@vanous
Copy link
Author

vanous commented Nov 1, 2018

that results in:

figure_1

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()

figure_2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment