| @@ -0,0 +1,27 @@ | |||
| 1 | + | import pandas as pd | |
| 2 | + | ||
| 3 | + | df = pd.read_csv("61b7cc82-fb4b-4c06-b26e-f76f61783c4e.csv") | |
| 4 | + | df['last_changed'] = pd.to_datetime(df['last_changed']) | |
| 5 | + | df['state'] = pd.to_numeric(df['state'], errors='coerce') | |
| 6 | + | ||
| 7 | + | # rozdělit na dva senzory | |
| 8 | + | inside = df[df['entity_id'].str.contains('timmerflotte')].set_index('last_changed')['state'].sort_index() | |
| 9 | + | outside = df[df['entity_id']=='sensor.teplota_venek'].set_index('last_changed')['state'].sort_index() | |
| 10 | + | ||
| 11 | + | print("timmerflotte: ", inside.min(), "-", inside.max(), "| rozsah času:", inside.index.min(), "->", inside.index.max()) | |
| 12 | + | print("teplota_venek: ", outside.min(), "-", outside.max(), "| rozsah času:", outside.index.min(), "->", outside.index.max()) | |
| 13 | + | print() | |
| 14 | + | ||
| 15 | + | # Sjednotit na společnou časovou osu pomocí forward-fill (step function - HA drží poslední hodnotu) | |
| 16 | + | combined = pd.concat([inside.rename('inside'), outside.rename('outside')], axis=1).sort_index() | |
| 17 | + | combined = combined.ffill().dropna() | |
| 18 | + | ||
| 19 | + | diff = combined['inside'] - combined['outside'] | |
| 20 | + | ||
| 21 | + | print("Počet zarovnaných bodů:", len(combined)) | |
| 22 | + | print() | |
| 23 | + | print(f"Průměrný rozdíl (vnitřní - venek): {diff.mean():+.3f} °C") | |
| 24 | + | print(f"Průměrný absolutní rozdíl |vnitřní-venek|: {diff.abs().mean():.3f} °C") | |
| 25 | + | print(f"Medián rozdílu: {diff.median():+.3f} °C") | |
| 26 | + | print(f"Min / Max rozdílu: {diff.min():+.3f} / {diff.max():+.3f} °C") | |
| 27 | + | print(f"Směrodatná odchylka rozdílu: {diff.std():.3f} °C") | |
david-spacil / teplotni-odchylka.py
Last active 1 month ago
david-spacil revised this gist 1 month ago · 5b9ef9b
1 file changed, 27 insertions