This file contains 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
def get_rows_before_charging(df): | |
df['battery_loss_next_row'] = df['battery'] - df['battery'].shift(-1) | |
df['is_low_before_charge'] = df['battery_loss_next_row'] < 0 | |
return df[df['is_low_before_charge']] |
This file contains 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
# it should return an empty DataFrame if the battery was never recharged | |
df_descending_only = build_battery_history([100,70,40,20]) | |
assert len( get_rows_before_charging(df_descending_only) ) == 0 |
This file contains 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 os | |
BATTERY_DATA_FILE = "battery-state-reports-last-30-days.csv" | |
df = pd.read_csv(os.path.join(os.getcwd(), BATTERY_DATA_FILE)) | |
df.dtypes |
This file contains 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
# it should return an empty DataFrame if the battery was never recharged | |
df_descending_only = # ??? | |
assert len( get_rows_before_charging(df_descending_only) ) == 0 |
This file contains 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 importlib |
This file contains 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
def get_rows_before_charging(df): | |
return df |
This file contains 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
def build_battery_history(values, device_id="60df87b4be3fc900069dac1f", start_time=1600000000000): | |
id_array = [device_id] * len(values) | |
timestamp_array = map(lambda t: start_time + t * 10000, range(len(values))) | |
return pd.DataFrame({ | |
"ID": pd.Series(id_array), | |
"battery": pd.Series(values, dtype="int64"), | |
"Timestamp": pd.Series(timestamp_array, dtype="int64") | |
}) |
This file contains 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 os |
This file contains 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
country=US | |
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev | |
update_config=1 | |
network={ | |
ssid="WIFI_SSID" | |
scan_ssid=1 | |
psk="WIFI_PASSWORD" | |
key_mgmt=WPA-PSK | |
} |
This file contains 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
const data = [ | |
{"location":"39.108314,-84.50959","isMoving":"1", "bearing":"SW","refrigeratorTemp":"35","freezerTemp":"2”}, | |
{"location":"39.107442,-84.50956","isMoving":"1", "bearing":"SSE","refrigeratorTemp":"38","freezerTemp":"5”}, | |
{"location":"39.106,-84.509303","isMoving":"1", "bearing":"SSE","refrigeratorTemp":"36","freezerTemp":"1}, | |
{"location":"39.105279,-84.508983","isMoving":"1", "bearing":"SSE","refrigeratorTemp":"35","freezerTemp":"-7”}, | |
{"location":"39.104119,-84.508712","isMoving":"1", "bearing":"SSE","refrigeratorTemp":"40","freezerTemp":"-9”}, | |
. | |
. | |
. | |
. |