fmtr.tools 1.0.40__py3-none-any.whl → 1.0.42__py3-none-any.whl

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.

Potentially problematic release.


This version of fmtr.tools might be problematic. Click here for more details.

@@ -1,6 +1,18 @@
1
1
  from pydantic import BaseModel, RootModel
2
2
 
3
3
 
4
+ def to_df(*objs):
5
+ """
6
+
7
+ DataFrame representation of Data Models as rows.
8
+
9
+ """
10
+ from fmtr.tools import tabular
11
+ rows = [obj.model_dump() for obj in objs]
12
+ df = tabular.DataFrame(rows)
13
+ return df
14
+
15
+
4
16
  class MixinFromJson:
5
17
 
6
18
  @classmethod
@@ -27,7 +39,22 @@ class Base(BaseModel, MixinFromJson):
27
39
  Base model
28
40
 
29
41
  """
30
- ...
42
+
43
+ def to_df(self):
44
+ """
45
+
46
+ DataFrame representation with Fields as rows.
47
+
48
+ """
49
+
50
+ objs = []
51
+ for name in self.model_fields.keys():
52
+ val = getattr(self, name)
53
+ objs.append(val)
54
+
55
+ df = to_df(*objs)
56
+ df['id'] = list(self.model_fields.keys())
57
+ return df
31
58
 
32
59
 
33
60
  class Root(RootModel, MixinFromJson):
@@ -36,4 +63,12 @@ class Root(RootModel, MixinFromJson):
36
63
  Root (list) model
37
64
 
38
65
  """
39
- ...
66
+
67
+ def to_df(self):
68
+ """
69
+
70
+ DataFrame representation with items as rows.
71
+
72
+ """
73
+
74
+ return to_df(*self.items)
@@ -148,10 +148,10 @@ class Mask:
148
148
  return self
149
149
 
150
150
 
151
- def to_mask(text):
151
+ def trim(text: str) -> str:
152
152
  """
153
153
 
154
- Fix multi-string indents.
154
+ Trim strings both horizontally and vertically. Useful when multiline strings are defined in an indented context.
155
155
 
156
156
  """
157
157
  return dedent(text).strip()
@@ -1,3 +1,4 @@
1
1
  import pandas as pd
2
2
 
3
3
  DataFrame = pd.DataFrame
4
+ Series = pd.Series
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.0.40
1
+ 1.0.42
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fmtr.tools
3
- Version: 1.0.40
3
+ Version: 1.0.42
4
4
  Summary: Collection of high-level tools to simplify everyday development tasks, with a focus on AI/ML
5
5
  Home-page: https://github.com/fmtr/fmtr.tools
6
6
  Author: Frontmatter
@@ -6,7 +6,7 @@ fmtr/tools/caching_tools.py,sha256=UOCYUNvLQ-NofR_dhqBmZF96-HRPf4At5MmxVk3gAIk,2
6
6
  fmtr/tools/config.py,sha256=5XllwShglvSqEl7Jt0EyObWHW4p-5QahkZjTAXdIXxc,715
7
7
  fmtr/tools/config_tools.py,sha256=27PbPYj90ClIW4QcRoUoiFM3SbWeMIIZsZR32IPU4V8,805
8
8
  fmtr/tools/console_script_tools.py,sha256=T968S6fL--84G5ALaKwcTAzUOFyVhTU7Ts6qbk8oaeE,65
9
- fmtr/tools/data_modelling_tools.py,sha256=bggZ-INJWr4depWC00lfXhzBtoFUOdon7Xahrj76vrY,574
9
+ fmtr/tools/data_modelling_tools.py,sha256=w0bnKbEJMFhWRMIof9mYsuSo-Vs8Tehw2_JY3NDL0VM,1242
10
10
  fmtr/tools/dataclass_tools.py,sha256=0Gt6KeLhtPgubo_2tYkIVqB8oQ91Qzag8OAGZDdjvMU,1209
11
11
  fmtr/tools/datatype_tools.py,sha256=3P4AWIFGkJ-UqvXlj0Jc9IvkIIgTOE9jRrOk3NVbpH8,1508
12
12
  fmtr/tools/docker_tools.py,sha256=rdaZje2xhlmnfQqZnR7IHgRdWncTLjrJcViUTt5oEwk,617
@@ -37,12 +37,12 @@ fmtr/tools/profiling_tools.py,sha256=jpXVjaNKPydTasEQVNXvxzGtMhXPit08AnJddkU8uIc
37
37
  fmtr/tools/random_tools.py,sha256=4VlQdk5THbR8ka4pZaLbk_ZO_4yy6PF_lHZes_rgenY,2223
38
38
  fmtr/tools/semantic_tools.py,sha256=cxY9NSAHWj4nEc6Oj4qA1omR3dWbl2OuH7_PkINc6_E,1386
39
39
  fmtr/tools/spaces_tools.py,sha256=D_he3mve6DruB3OPS6QyzqD05ChHnRTb4buViKPe7To,1099
40
- fmtr/tools/string_tools.py,sha256=0aAaLS7JPzCaanuyVT3YyonFbEZyimSAdesHRX_Ew6c,3362
41
- fmtr/tools/tabular_tools.py,sha256=lJ3hk-uTIddt6eXE5uEpFK4pnP3hPzCL64PckFswMpU,46
40
+ fmtr/tools/string_tools.py,sha256=9zsqShVf1VUfD7hsJBYcuk43L3qCKm1eVwGBn1-wK9Q,3458
41
+ fmtr/tools/tabular_tools.py,sha256=L0yNsU_c8dGTmsUlMFERfTt2a3aZv_pKr2YQc7C9OvA,65
42
42
  fmtr/tools/tokenization_tools.py,sha256=9FP5vgPufWv0XA961eVKObFll0d_2mM0W3ut3rtZyeo,4329
43
43
  fmtr/tools/tools.py,sha256=xnfUrOnrT4OxFYez6vV5tAhydzCICJFiGVnviiZDEQo,796
44
44
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
45
- fmtr/tools/version,sha256=GotUYjLRWrcavUYKHcbuoAYqgrQefl8MFctyfNIMEg8,6
45
+ fmtr/tools/version,sha256=YqbU0sZsDgmmNeKnzFVI1oDZwrUn8Iw7CVo10rO5hJQ,6
46
46
  fmtr/tools/version_tools.py,sha256=axzzHBS9V1n6YuSacsDKG3VfAvRqR8qr6aENCibR8vs,1248
47
47
  fmtr/tools/yaml_tools.py,sha256=Ol43ZwbnSXGnn1K98Uxx61KPGSqfC4axE-X2q1LKMwk,349
48
48
  fmtr/tools/ai_tools/__init__.py,sha256=4VO4uyO2ZBzLVB63DYAVsv1qMT9NX39B9P5YCaPrfto,373
@@ -56,9 +56,9 @@ fmtr/tools/tests/test_environment.py,sha256=iHaiMQfECYZPkPKwfuIZV9uHuWe3aE-p_dN_
56
56
  fmtr/tools/tests/test_json.py,sha256=IeSP4ziPvRcmS8kq7k9tHonC9rN5YYq9GSNT2ul6Msk,287
57
57
  fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g,2188
58
58
  fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
59
- fmtr.tools-1.0.40.dist-info/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
60
- fmtr.tools-1.0.40.dist-info/METADATA,sha256=L086zjSWUjZksNxMyzNc0QkZ99NpQ6tasGGCrxlLlyQ,13859
61
- fmtr.tools-1.0.40.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
62
- fmtr.tools-1.0.40.dist-info/entry_points.txt,sha256=CEStVkwJ1mTFvhN1WV5RdW83SkNW1d5Syj-KZ6A19ng,72
63
- fmtr.tools-1.0.40.dist-info/top_level.txt,sha256=t5341a8ii3n4RFizwTeXGmcq_pf4GqL1h9ylE5LIWRk,12
64
- fmtr.tools-1.0.40.dist-info/RECORD,,
59
+ fmtr.tools-1.0.42.dist-info/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
60
+ fmtr.tools-1.0.42.dist-info/METADATA,sha256=QHrueQAoU2QQ-JJM_hsR6MtdU9p6qOBtAST7GiBz3bs,13859
61
+ fmtr.tools-1.0.42.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
62
+ fmtr.tools-1.0.42.dist-info/entry_points.txt,sha256=CEStVkwJ1mTFvhN1WV5RdW83SkNW1d5Syj-KZ6A19ng,72
63
+ fmtr.tools-1.0.42.dist-info/top_level.txt,sha256=t5341a8ii3n4RFizwTeXGmcq_pf4GqL1h9ylE5LIWRk,12
64
+ fmtr.tools-1.0.42.dist-info/RECORD,,