dimwit 0.2.6__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dimwit-0.2.6 → dimwit-0.2.7}/PKG-INFO +1 -1
- {dimwit-0.2.6 → dimwit-0.2.7}/dimwit/main.py +26 -2
- {dimwit-0.2.6 → dimwit-0.2.7}/pyproject.toml +1 -1
- {dimwit-0.2.6 → dimwit-0.2.7}/README.md +0 -0
- {dimwit-0.2.6 → dimwit-0.2.7}/dimwit/__init__.py +0 -0
- {dimwit-0.2.6 → dimwit-0.2.7}/dimwit/air_pollution.py +0 -0
- {dimwit-0.2.6 → dimwit-0.2.7}/dimwit/legacy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dimwit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: A package containing various functions and classes for fetching, transforming, and visualising data for personal metrics.
|
|
5
5
|
Home-page: https://github.com/danielsoutar/dimwit
|
|
6
6
|
Author: Daniel Soutar
|
|
@@ -2,7 +2,7 @@ import datetime as dat
|
|
|
2
2
|
import dateutil
|
|
3
3
|
|
|
4
4
|
# Import matplotlib before pandas to avoid import ordering issues.
|
|
5
|
-
import matplotlib.pyplot as plt
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
6
|
import pandas as pd
|
|
7
7
|
import requests
|
|
8
8
|
import numpy as np
|
|
@@ -340,9 +340,12 @@ def get_aggregated_event_counts(ts, events, period):
|
|
|
340
340
|
df = df.pivot_table(
|
|
341
341
|
index="date", columns="categories", values="value", aggfunc="sum"
|
|
342
342
|
)
|
|
343
|
-
if period not in ["weekly", "daily"]:
|
|
343
|
+
if period.lower() not in ["monthly", "weekly", "daily"]:
|
|
344
344
|
raise Exception("Period argument not recognised")
|
|
345
345
|
|
|
346
|
+
if period == "monthly":
|
|
347
|
+
grouped_df = df.groupby([pd.Grouper(freq="ME")]).sum()
|
|
348
|
+
|
|
346
349
|
if period == "weekly":
|
|
347
350
|
df.index = df.index - pd.to_timedelta(7, unit="d")
|
|
348
351
|
grouped_df = df.groupby([pd.Grouper(freq="W")]).sum()
|
|
@@ -366,3 +369,24 @@ def populate_with_events(ax, events, from_date):
|
|
|
366
369
|
label=event_label,
|
|
367
370
|
)
|
|
368
371
|
return ax
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def plot_category(
|
|
375
|
+
title, df, categories, window_size, round_size, round_unit, from_date=None
|
|
376
|
+
):
|
|
377
|
+
fig, ax = plt.subplots(1, 1, figsize=(12, 6))
|
|
378
|
+
ax.set_title(title)
|
|
379
|
+
for category in categories:
|
|
380
|
+
if from_date is not None:
|
|
381
|
+
ax = df[from_date:].plot(y=category, ax=ax)
|
|
382
|
+
else:
|
|
383
|
+
ax = df.plot(y=category, ax=ax)
|
|
384
|
+
ax.set_xlabel("Time")
|
|
385
|
+
ax.set_ylabel("Frequency")
|
|
386
|
+
ax.legend(
|
|
387
|
+
[
|
|
388
|
+
f"{category} ({str(round_size) + round_unit}, k={window_size})"
|
|
389
|
+
for category in categories
|
|
390
|
+
],
|
|
391
|
+
)
|
|
392
|
+
return fig, ax
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "dimwit"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.7"
|
|
4
4
|
description = "A package containing various functions and classes for fetching, transforming, and visualising data for personal metrics."
|
|
5
5
|
authors = ["Daniel Soutar <danielsoutar144@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|