Comfort Donuts

Comfort Donuts#

Goal

Summarize how much of the time temperature and humidity stay below, within or above the comfort band — as two donut charts with per-slice counts and the average / min–max in the center.

Data Basis

We use the bundled dataset room_climate_sample.csv shipped with pyedautils — anonymized hourly temperature and humidity from a real sensor in a cool, humidity-controlled room. It is loaded directly from the installed package (importlib.resources), so no download is needed.

Data Preparation#

import pandas as pd
from importlib import resources

data_path = resources.files("pyedautils") / "data" / "room_climate_sample.csv"
df = pd.read_csv(data_path, parse_dates=["timestamp"])

# daily means -> counts are days (the CSV is hourly)
daily = df.set_index("timestamp").resample("D").mean()
daily.head()
humidity temperature
timestamp
2025-05-01 50.886957 19.494348
2025-05-02 51.165217 20.142609
2025-05-03 52.508333 20.658333
2025-05-04 52.613636 20.567727
2025-05-05 48.600000 19.677000

Visualization#

from pyedautils.plots import plot_comfort_donuts

# Cool, humidity-controlled room -> target band 8-18 deg C / 40-70 %rH.
fig = plot_comfort_donuts(daily, temp_range=(8, 18), hum_range=(40, 70),
                          title="Time within comfort range")
fig.show()
Customization

Adjust the comfort band via temp_range and hum_range. Each donut shows the slice shares, its own legend with counts and percentages, and the average with the min–max range in the center (show_center_stats=False hides it).

fig = plot_comfort_donuts(daily, temp_range=(20, 26), hum_range=(30, 65))