<jupyter_start><jupyter_text>In this notebook we show plotting of some numerical sensor data<jupyter_code>!pip show HASS-data-detective|grep Version
import detective.core as detective
import pandas as pd
%matplotlib inline
pd.options.mode.chained_assignment = None  # Suppress chained_assignment warning, default='warn'
%%time
db = detective.HassDatabase('sqlite:///data/home-assistant_v2.db') 
%%time
db.fetch_all_data()
db.entities['sensor']
from detective.core import NumericalSensors
numerical_sensors = NumericalSensors(db.master_df)
numerical_sensors.data.head()
numerical_sensors.entities<jupyter_output><empty_output><jupyter_text>We can get the summary stats for a single sensor<jupyter_code>numerical_sensors.data['sensor.particles_10um'].describe()<jupyter_output><empty_output><jupyter_text>We have a helper function `correlations()` to calculate the correlation between sensors<jupyter_code>numerical_sensors.correlations()[:3] # top 3 correlations<jupyter_output><empty_output><jupyter_text>We use a convenience function to plot these sensors, but the function is a bit limited<jupyter_code>entities = ['sensor.particles_01um',
            'sensor.particles_10um']

numerical_sensors.plot(entities)<jupyter_output><empty_output><jupyter_text>We can create the same plot directly<jupyter_code>ax = numerical_sensors.data[entities].plot(figsize=[12, 6])
ax.legend(loc="center left", bbox_to_anchor=(1, 0.5))
ax.set_xlabel("Date")
ax.set_ylabel("Reading")<jupyter_output><empty_output><jupyter_text>We can filter the daterange of data shown using the `.loc` attribute of the dataframe<jupyter_code>numerical_sensors.data[entities].loc['2018-12-04 09:36:00':'2018-12-04 9:38:00'].plot(figsize=[12, 6]);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11308840413318025, 'fraction_numerical': 0.025832376578645237, 'mean_word_length': 8.737430167597765, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '449713', 'license': 'MIT', 'n_tokens_mistral': 621, 'n_tokens_neox': 578, 'n_words': 116, 'path': 'Introduction_to_plotting_sensor_data.ipynb', 'repo_name': 'robmarkcole/HASS-data-detective-analysis', 'size': '1742'}