tesorotools-python 0.0.19__tar.gz → 0.0.21__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.
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/PKG-INFO +1 -1
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/pyproject.toml +1 -1
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/table.py +7 -0
- tesorotools_python-0.0.21/tesorotools/utils/__init__.py +3 -0
- tesorotools_python-0.0.21/tesorotools/utils/format.py +38 -0
- tesorotools_python-0.0.19/tesorotools/utils/__init__.py +0 -1
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/.gitignore +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/artists/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/artists/barh_plot.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/artists/line_plot.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/artists/table.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/artists/type_curve.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/README.md +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Black.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Bold.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Extrabold.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Extralight.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Light.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Medium.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Regular.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/CabinetGrotesk-Thin.otf +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/fonts/README.md +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/plots.yaml +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/assets/tesoro.mplstyle +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/convert.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/data_sources/README.md +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/data_sources/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/data_sources/debug.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/data_sources/lseg.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/database/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/database/local.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/database/push.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/functions.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/node.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/resolution.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/main.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/offsets/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/offsets/offsets.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/offsets/outliers.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/__init__.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/content.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/images.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/section.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/subtitle.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/text.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/title.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/report.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/utils/config.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/utils/globals.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/utils/matplotlib.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/utils/series.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/utils/shortcuts.py +0 -0
- {tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/utils/template.py +0 -0
|
@@ -251,6 +251,7 @@ class Table:
|
|
|
251
251
|
shade_file: Path | None = None,
|
|
252
252
|
block_sep: bool = False,
|
|
253
253
|
title: str | None = None,
|
|
254
|
+
columns: list[str] | None = None,
|
|
254
255
|
):
|
|
255
256
|
if (
|
|
256
257
|
(data_file is None)
|
|
@@ -267,6 +268,12 @@ class Table:
|
|
|
267
268
|
self._shade: pd.DataFrame | None = (
|
|
268
269
|
pd.read_feather(shade_file) if shade_file is not None else None
|
|
269
270
|
)
|
|
271
|
+
|
|
272
|
+
if columns is not None:
|
|
273
|
+
self._data = self._data[columns]
|
|
274
|
+
self._color = self._color[columns]
|
|
275
|
+
self._shade = self._shade[columns]
|
|
276
|
+
|
|
270
277
|
self._title: str | None = title
|
|
271
278
|
self._block_sep: bool = block_sep
|
|
272
279
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
from tesorotools.utils.matplotlib import format_annotation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def format_table(
|
|
9
|
+
table: pd.DataFrame, format_dict: dict[str, dict[str, Any]]
|
|
10
|
+
) -> pd.DataFrame:
|
|
11
|
+
"""Formats a pandas dataframe to get it ready for being rendered into a .docx file.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
table : pd.DataFrame
|
|
16
|
+
format_dict : dict[str, dict[str, Any]]
|
|
17
|
+
Each key in the dictionary is a column in the dataframe, each value is a dictionary with 3 possible entries: "scale" (integer, default=1), "decimals" (integer, default=0), "units" (string, default="").
|
|
18
|
+
|
|
19
|
+
Returns
|
|
20
|
+
-------
|
|
21
|
+
pd.DataFrame
|
|
22
|
+
The formatted dataframe
|
|
23
|
+
"""
|
|
24
|
+
for column, fmt in format_dict.items():
|
|
25
|
+
if pd.api.types.is_numeric_dtype(table[column]):
|
|
26
|
+
scale = fmt.get("scale", 1)
|
|
27
|
+
table[column] = table[column] / scale
|
|
28
|
+
table[column] = table[column].apply(
|
|
29
|
+
lambda x: format_annotation(
|
|
30
|
+
value=x,
|
|
31
|
+
decimals=fmt.get("decimals", 0),
|
|
32
|
+
units=fmt.get("units", ""),
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
for column in table.columns:
|
|
37
|
+
table[column] = table[column].astype(str)
|
|
38
|
+
return table
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from tesorotools.utils.globals import SYSTEM
|
|
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
|
|
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
|
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/data_sources/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/dependencies/resolution.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/content.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/images.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/section.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.19 → tesorotools_python-0.0.21}/tesorotools/render/content/subtitle.py
RENAMED
|
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
|