<jupyter_start><jupyter_text>- title: HVAC Review Using Sidetable- date: 2021-04-11 16:00- tags: hvac, python, notebook, sidetable- author: Christopher- summary: Use Sidetable and Jupyter Notebook to do some analysis.- category: Python  Problem StatementReview the HVAC data and show how bad the refrigeration leak is. DescriptionI used a Rasperry Pi and some thermocouples to measure the inlet andoutlet of my HVAC system.The temperature delta should be 18F when the AC kicks on. Data SourcesI have the data in a PostgreSQL database.For the purposes of this post, I will provide the data in a CSV file. OverviewThis post will go through and use sidetable to help with some basicanalysis.<jupyter_code>import pandas as pd
import numpy as np
from pathlib import Path
from datetime import datetime
import seaborn as sns
import sidetable
# Use to see the value of multiple statements at once.
from IPython.core.interactiveshell import InteractiveShell

InteractiveShell.ast_node_interactivity = "all"

# See matplotlib/Seaborn in notebook
%matplotlib inline

sns.set( style = "white" )<jupyter_output><empty_output><jupyter_text>Load the DataThe data is located in my[data repo](https://github.com/cetyler/github_data/hvac_review).I would suggest that you download the data to your PC.<jupyter_code>today = datetime.today()
project_folder = Path.cwd()
raw_file = (
    "https://raw.githubusercontent.com/cetyler/github_data/main/hvac_review/hvac_Apr-10-2021.csv"
)
df = pd.read_csv(raw_file)
df.head()<jupyter_output><empty_output><jupyter_text>Probably don't need any of the basement data.Will filter out basement data and also don't need humidity either.<jupyter_code>mask = df["location"] != "Basement"
df = df[mask]

df = df[["timestamp", "name", "temperature"]]
df.head()
df.dtypes<jupyter_output><empty_output><jupyter_text>The last bit is to create a temperature difference column and sort the data.<jupyter_code>df.drop_duplicates(subset=["timestamp", "name"], inplace=True)
df["timestamp"] = pd.to_datetime(df["timestamp"])
df.set_index("timestamp", inplace=True)

df = df.sort_values(by="timestamp")

df["diff"] = df["temperature"].diff()
df["diff_abs"] = abs(df["temperature"].diff().round(0))
df.head()<jupyter_output><empty_output><jupyter_text>Notice that I created a column with the absolute difference and I rounded thevalues.  Initial AnalysisLet's see how using sidetable can help understand the data some more.<jupyter_code>df.stb.freq(["diff_abs"]).head(10)<jupyter_output><empty_output><jupyter_text>This data is showing that the highest difference is 11F while 18F is pretty fardown.However this could be due to how long it takes for my AC to get to the maxdifference.This may require a chart.<jupyter_code>g = sns.relplot(data=df, x="timestamp", y="temperature", hue="name" ,kind="scatter")
g.set_xticklabels(rotation=30)<jupyter_output><empty_output><jupyter_text>This shows that a good chunk of my data is when the heat was on.Will filter the data to stop at the end of September.<jupyter_code>df_ac = df[df.index < datetime(2020, 9, 29, 0, 0)]
g = sns.relplot(data=df_ac, x="timestamp", y="temperature", hue="name" ,kind="scatter")
g.set_xticklabels(rotation=30)<jupyter_output><empty_output><jupyter_text>Now let's look at temperature difference.I will only look at the Outlet difference.The way I calculated the difference by subtracting from the previous row,Outlet (Inlet - Outlet) whereas the value for Inlet (Outlet - Inlet).<jupyter_code>g = sns.relplot(data=df_ac[df_ac["name"] == "Outlet"], x="timestamp", y="diff", kind="scatter")
g.set_xticklabels(rotation=30)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1054083885209713, 'fraction_numerical': 0.011589403973509934, 'mean_word_length': 6.3979591836734695, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '370200', 'license': 'MIT', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1133, 'n_words': 372, 'path': 'content/python/2021-04-11-hvac_review.ipynb', 'repo_name': 'cetyler/github_pelican', 'size': '3624'}