typedparser 0.5.3__tar.gz → 0.6.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.5.3
3
+ Version: 0.6.2
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
5
  Author: gingsi
6
6
  License: Apache-2.0
@@ -14,4 +14,4 @@ __all__ = [
14
14
  "CustomArgparseFmt",
15
15
  "get_attr_names",
16
16
  ]
17
- __version__ = "0.5.3"
17
+ __version__ = "0.6.2"
@@ -312,3 +312,23 @@ def big_obj_to_short_str(d: Any) -> str:
312
312
  return f"{class_name} len {len(d)}"
313
313
  except TypeError:
314
314
  return f"Object of type {class_name}"
315
+
316
+
317
+ def invert_dictionary(inv_dict: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
318
+ """
319
+ Invert a dictionary of dictionaries. Useful for creating dataframes.
320
+
321
+ Args:
322
+ inv_dict: dictionary of {key1: {field1: value1, field2: value2, ...}, ...}
323
+
324
+ Returns:
325
+ Dictionary of {field1: {key1: value1, key2: value2, ...}, ...}
326
+
327
+ """
328
+ regular_dict = {}
329
+ for key, value_dict in inv_dict.items():
330
+ for field, value in value_dict.items():
331
+ if field not in regular_dict:
332
+ regular_dict[field] = {}
333
+ regular_dict[field][key] = value
334
+ return regular_dict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.5.3
3
+ Version: 0.6.2
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
5
  Author: gingsi
6
6
  License: Apache-2.0
File without changes
File without changes
File without changes
File without changes