diff --git a/AUTHORS.md b/AUTHORS.md index 34f8f69..85a84db 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -58,3 +58,4 @@ Authors in order of the timeline of their contributions: - [kor4ik](https://github.com/kor4ik) for the bugfix for `include_paths` for nested dictionaries. - [martin-kokos](https://github.com/martin-kokos) for using tomli and tomli-w for dealing with tomli files. - [Alex Sauer-Budge](https://github.com/amsb) for the bugfix for `datetime.date`. +- [William Jamieson](https://github.com/WilliamJamieson) for [NumPy 2.0 compatibility](https://github.com/seperman/deepdiff/pull/422) diff --git a/README.md b/README.md index 6702b97..7524209 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,11 @@ Tested on Python 3.7+ and PyPy3. Please check the [ChangeLog](CHANGELOG.md) file for the detailed information. +DeepDiff 6-6-0 + +- [Serialize To Flat Dicts]() +- [NumPy 2.0 compatibility](https://github.com/seperman/deepdiff/pull/422) by [William Jamieson](https://github.com/WilliamJamieson) + DeepDiff 6-5-0 - [parse_path](https://zepworks.com/deepdiff/current/faq.html#q-how-do-i-parse-deepdiff-result-paths) @@ -66,10 +71,21 @@ Install optional packages: Please take a look at the [CHANGELOG](CHANGELOG.md) file. +# 🛠️ Detect And Clean Messy Data In Transit + +If you deal with messy data, check out [Qluster](https://qluster.ai/solution), another tool by the creator of DeepDiff. + +*Qluster's mission is to enable users to create adaptive data pipelines that detect issues, quarantine bad data, and enable the user to fix data issues via a spreadsheet UI.* + + # Survey :mega: **Please fill out our [fast 5-question survey](https://forms.gle/E6qXexcgjoKnSzjB8)** so that we can learn how & why you use DeepDiff, and what improvements we should make. Thank you! :dancers: +# Data Cleaning + + + # Contribute diff --git a/docs/authors.rst b/docs/authors.rst index 1720469..34fea1a 100644 --- a/docs/authors.rst +++ b/docs/authors.rst @@ -83,6 +83,8 @@ Authors in order of the timeline of their contributions: and tomli-w for dealing with tomli files. - `Alex Sauer-Budge `__ for the bugfix for ``datetime.date``. +- `William Jamieson `__ for `NumPy 2.0 +compatibility `__ .. _Sep Dehpour (Seperman): http://www.zepworks.com .. _Victor Hahn Castell: http://hahncastell.de diff --git a/docs/delta.rst b/docs/delta.rst index 235332a..b1b7e43 100644 --- a/docs/delta.rst +++ b/docs/delta.rst @@ -208,6 +208,14 @@ Delta Serializer DeepDiff uses pickle to serialize delta objects by default. Please take a look at the :ref:`delta_deserializer_label` for more information. + +.. _to_flat_dicts: + +Delta Serialize To Flat Dictionaries +------------------------------------ + +Read about :ref:`delta_to_flat_dicts_label` + .. _delta_dump_safety_label: Delta Dump Safety @@ -472,7 +480,7 @@ Unable to get the item at root['x']['y'][3]: 'x' Unable to get the item at root['q']['t'] {} -# Once we set the force to be True +Once we set the force to be True >>> delta = Delta(diff, force=True) >>> {} + delta diff --git a/docs/index.rst b/docs/index.rst index f193998..1f4fab9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -31,6 +31,12 @@ The DeepDiff library includes the following modules: What Is New *********** +DeepDiff 6-6-0 +-------------- + + - :ref:`delta_to_flat_dicts_label` can be used to serialize delta objects into a flat list of dictionaries. + - `NumPy 2.0 compatibility `__ by `William Jamieson `__ + DeepDiff 6-5-0 -------------- diff --git a/docs/serialization.rst b/docs/serialization.rst index 3b409f1..b3a49a9 100644 --- a/docs/serialization.rst +++ b/docs/serialization.rst @@ -105,4 +105,48 @@ From Json Pickle Load the diff object from the json pickle dump. Take a look at the above :ref:`to_json_pickle_label` for an example. + +.. _delta_to_flat_dicts_label: + +Delta Serialize To Flat Dictionaries +------------------------------------ + +Sometimes, it is desired to serialize a :ref:`delta_label` object to a list of flat dictionaries. For example, to store them in relation databases. In that case, you can use the Delta.to_flat_dicts to achieve the desired outcome. + +For example: + + >>> from pprint import pprint + >>> from deepdiff import DeepDiff, Delta + >>> t1 = {"key1": "value1"} + >>> t2 = {"field2": {"key2": "value2"}} + >>> diff = DeepDiff(t1, t2, verbose_level=2) + >>> pprint(diff, indent=2) + { 'dictionary_item_added': {"root['field2']": {'key2': 'value2'}}, + 'dictionary_item_removed': {"root['key1']": 'value1'}} + >>> + >>> delta = Delta(diff, verify_symmetry=True) + >>> flat_dicts = delta.to_flat_dicts() + >>> pprint(flat_dicts, indent=2) + [ { 'action': 'dictionary_item_added', + 'path': ['field2', 'key2'], + 'value': 'value2'}, + {'action': 'dictionary_item_removed', 'path': ['key1'], 'value': 'value1'}] + + +Example 2: + + >>> t3 = ["A", "B"] + >>> t4 = ["A", "B", "C", "D"] + >>> diff = DeepDiff(t3, t4, verbose_level=2) + >>> pprint(diff, indent=2) + {'iterable_item_added': {'root[2]': 'C', 'root[3]': 'D'}} + >>> + >>> delta = Delta(diff, verify_symmetry=True) + >>> flat_dicts = delta.to_flat_dicts() + >>> pprint(flat_dicts, indent=2) + [ {'action': 'iterable_item_added', 'path': [2], 'value': 'C'}, + {'action': 'iterable_item_added', 'path': [3], 'value': 'D'}] + + + Back to :doc:`/index`