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
from nilmtk.plots import latexify, format_axes | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
df_idx=pd.date_range(start="2014-01-01", freq="D", periods=7) | |
normal = pd.Series([75,83,75,79,49,74,83],index=df_idx) | |
off_peak = pd.Series([53,50,48,56,44,42,58],index=df_idx) | |
peak = pd.Series([43,42,44,34,28,47,41],index=df_idx) | |
df = pd.DataFrame({'peak':peak,'normal':normal,'off peak':off_peak}, index=df_idx) | |
from mpltools import style | |
style.use('ggplot') |
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
In [1]: import pandas as pd | |
In [2]: df1=pd.read_csv("1.csv", index_col=1, parse_dates=True) | |
In [3]: df2=pd.read_csv("2.csv", index_col=1, parse_dates=True) | |
In [4]: df1.head(5) | |
Out[4]: | |
id temp pir reed | |
timestamp | |
2012-01-16 16:46:28 0 23.25 1 0 | |
2012-01-16 16:46:29 1 23.10 1 0 | |
2012-01-16 16:46:30 2 23.20 0 0 |
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
In [147]: ser.values[0] | |
Out[147]: {u'accuracy': 0, u'lux': 90.0, u'timestamp': 1369176076.891088} | |
In [148]: ser.values | |
Out[148]: | |
array([{u'lux': 90.0, u'timestamp': 1369176076.891088, u'accuracy': 0}, | |
{u'lux': 90.0, u'timestamp': 1369176076.891088, u'accuracy': 0}, | |
{u'lux': 90.0, u'timestamp': 1369176076.891088, u'accuracy': 0}, | |
..., | |
{u'lux': 40.0, u'timestamp': 1372336580.332052, u'accuracy': 0}, |
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
In [112]: sql = "select timestamp, value from data where probe='edu.mit.media.funf.probe.builtin.BatteryProbe'" | |
In [113]: df = psql.frame_query(sql, con) | |
In [114]: df.index = pd.to_datetime(df.timestamp, unit='s') | |
In [115]: df = df.drop("timestamp", 1) | |
In [117]: ser = df.value.apply(json.loads) | |
In [120]: ser.values[0] | |
Out[120]: | |
{u'health': 2, | |
u'icon-small': 17303134, | |
u'invalid_charger': 0, |
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
In [74]: sql = "select timestamp, value from data where probe='edu.mit.media.funf.probe.builtin.AudioFeaturesProbe'" | |
In [75]: df = psql.frame_query(sql, con) | |
In [76]: df.index = pd.to_datetime(df.timestamp, unit='s') | |
In [77]: df = df.drop("timestamp", 1) | |
In [79]: ser = df.value.apply(json.loads) | |
In [82]: ser.values[0] | |
Out[82]: | |
{u'diffSecs': 1.0540001392364502, | |
u'l1Norm': 68.381625, | |
u'l2Norm': 110.89188822903144, |
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
In [60]: sql = "select timestamp, value from data where probe='edu.mit.media.funf.probe.builtin.WifiProbe'" | |
In [61]: df = psql.frame_query(sql, con) | |
In [62]: df.index = pd.to_datetime(df.timestamp, unit='s') | |
In [63]: df = df.drop("timestamp", 1) | |
In [65]: ser = df.value.apply(json.loads) | |
In [67]: ser.values[0] | |
Out[67]: | |
{u'BSSID': u'80:a1:d7:bb:e5:0c', | |
u'SSID': u'NoNetworkFound', | |
u'capabilities': u'[WEP][ESS]', |
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
In [57]: con = lite.connect("/home/nipun/Desktop/funf/first_floor_small.db") | |
In [58]: sql = "select distinct probe from data" | |
In [59]: df = psql.frame_query(sql, con) | |
In [60]: df.probe.values | |
Out[60]: | |
array([u'edu.mit.media.funf.probe.builtin.AccelerometerSensorProbe', | |
u'edu.mit.media.funf.probe.builtin.CellTowerProbe', | |
u'edu.mit.media.funf.probe.builtin.LocationProbe', | |
u'edu.mit.media.funf.probe.builtin.BatteryProbe', | |
u'edu.mit.media.funf.probe.builtin.ProximitySensorProbe', |
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
In [100]: mac_to_name.values() | |
Out[100]: | |
[u'Mukund', | |
u'Wave Y', | |
u'BlackBerry 9220', | |
u'LP-DELHI-NEHA-A', | |
u'Father', | |
u'ubuntu-0', | |
u'Mother', | |
u'aaron', |
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
python dbdecrypt.py *.db | |
python dbmerge.py *.db |
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 pandas as pd | |
import pandas.io.sql as psql | |
import sqlite3 as lite | |
import json | |
con = lite.connect("/home/nipun/Desktop/funf/first_floor_small.db") | |
sql = "select timestamp, probe, value from data" | |
df = psql.frame_query(sql, con) | |
#Filter bluetooth content |