apmtools 0.2.17__tar.gz → 0.2.18__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.
- {apmtools-0.2.17 → apmtools-0.2.18}/PKG-INFO +1 -1
- {apmtools-0.2.17 → apmtools-0.2.18}/pyproject.toml +1 -1
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/shiny/summary.py +11 -18
- {apmtools-0.2.17 → apmtools-0.2.18}/.gitignore +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/LICENSE +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/README.md +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/__init__.py +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/classes.py +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/data_processing.py +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/functions.py +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/legacy.py +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/shiny/__init__.py +0 -0
- {apmtools-0.2.17 → apmtools-0.2.18}/src/apmtools/units.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: apmtools
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.018
|
|
4
4
|
Summary: A collection of tools for processing air pollution monitoring data
|
|
5
5
|
Project-URL: Homepage, https://github.com/federlorenz/apmtools
|
|
6
6
|
Author-email: Federico Lorenzetti <lorenzetti.federico@gmail.com>
|
|
@@ -16,7 +16,6 @@ PLOT_TYPES = {
|
|
|
16
16
|
"scatter": "Scatter",
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
# ``None`` means row-level plotting. The other values are passed directly to
|
|
21
20
|
# Summary.group_stat(frequency=...).
|
|
22
21
|
FREQUENCIES = {
|
|
@@ -100,7 +99,8 @@ def _timedelta_columns(data: pd.DataFrame) -> list[str]:
|
|
|
100
99
|
key=str.casefold,
|
|
101
100
|
)
|
|
102
101
|
|
|
103
|
-
|
|
102
|
+
|
|
103
|
+
def _normalise_y(data: pd.DataFrame, x: str, y: str | Sequence[str] | None) -> list[str]:
|
|
104
104
|
"""Validate and normalise an initial Y selection."""
|
|
105
105
|
numeric = _numeric_columns(data)
|
|
106
106
|
if y is None:
|
|
@@ -179,16 +179,6 @@ def _aggregate(data, value_columns, frequency, grouping_by, aggregate):
|
|
|
179
179
|
return result
|
|
180
180
|
|
|
181
181
|
|
|
182
|
-
def _aggregated_value_columns(data, value_columns, aggregate):
|
|
183
|
-
"""Return the columns produced by Summary.group_stat()."""
|
|
184
|
-
columns = []
|
|
185
|
-
for column in value_columns:
|
|
186
|
-
aggregated = f"{column}_{aggregate}"
|
|
187
|
-
if aggregated in data.columns:
|
|
188
|
-
columns.append(aggregated)
|
|
189
|
-
return columns
|
|
190
|
-
|
|
191
|
-
|
|
192
182
|
def _frequency_timedelta(frequency: str) -> pd.Timedelta | None:
|
|
193
183
|
"""Convert a timestamp aggregation frequency to its expected spacing."""
|
|
194
184
|
if not frequency or frequency == "weekday":
|
|
@@ -300,16 +290,17 @@ def create_summary_app(
|
|
|
300
290
|
columns = _alphabetical(summary.columns)
|
|
301
291
|
column_map = {str(c): c for c in summary.columns}
|
|
302
292
|
numeric_columns = _alphabetical(_numeric_columns(summary))
|
|
303
|
-
categorical_columns =
|
|
304
|
-
datetime_columns =
|
|
305
|
-
|
|
306
|
-
|
|
293
|
+
categorical_columns = _categorical_columns(summary)
|
|
294
|
+
datetime_columns = _datetime_columns(summary)
|
|
295
|
+
group_columns = _alphabetical(
|
|
296
|
+
c for c in columns if not pd.api.types.is_numeric_dtype(summary[column_map[c]])
|
|
297
|
+
)
|
|
307
298
|
|
|
308
299
|
x = _default_x(summary) if x is None else str(x)
|
|
309
300
|
if x not in column_map:
|
|
310
301
|
raise ValueError(f"Unknown x column: {x!r}")
|
|
311
302
|
|
|
312
|
-
initial_y =
|
|
303
|
+
initial_y = _normalise_y(summary, x, y)
|
|
313
304
|
if group_by is None:
|
|
314
305
|
initial_groups = [_default_group(summary)] if _default_group(
|
|
315
306
|
summary) is not None else []
|
|
@@ -320,6 +311,8 @@ def create_summary_app(
|
|
|
320
311
|
unknown_groups = [c for c in initial_groups if c not in column_map]
|
|
321
312
|
if unknown_groups:
|
|
322
313
|
raise ValueError(f"Unknown group_by column(s): {unknown_groups!r}")
|
|
314
|
+
# Numeric columns are not offered by the Group by selector.
|
|
315
|
+
initial_groups = [c for c in initial_groups if c in group_columns]
|
|
323
316
|
|
|
324
317
|
if plot_type not in PLOT_TYPES:
|
|
325
318
|
raise ValueError(
|
|
@@ -336,7 +329,7 @@ def create_summary_app(
|
|
|
336
329
|
ui.output_ui("y_control"),
|
|
337
330
|
ui.input_selectize(
|
|
338
331
|
"group_by", "Group by",
|
|
339
|
-
choices={c: c for c in
|
|
332
|
+
choices={c: c for c in group_columns},
|
|
340
333
|
selected=initial_groups,
|
|
341
334
|
multiple=True,
|
|
342
335
|
options={"placeholder": "Select one or more grouping columns"},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|