From ee4ffa6deb658dc114d385fabc4af46cb7ab95f8 Mon Sep 17 00:00:00 2001 From: Matheus Lins Date: Thu, 30 Jan 2020 13:47:43 -0300 Subject: [PATCH] Update README.rst --- README.rst | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.rst b/README.rst index 75dc7dd..a0fc4ff 100644 --- a/README.rst +++ b/README.rst @@ -219,6 +219,47 @@ To get the number of occurrence of the given key/value print(no_of_value_occurrence) # result => 1 +To get the number of occurrence and their respective values + +.. code-block:: python + + from nested_lookup import get_occurrences_and_values + + my_documents = [ + { + "processor_name": "4", + "processor_speed": "2.7 GHz", + "core_details": { + "total_numberof_cores": "4", + "l2_cache(per_core)": "256 KB", + } + } + ] + + result = get_occurrences_and_values(my_documents, value='4') + + print(result) + + { + "4": { + "occurrences": 2, + "values": [ + { + "processor_name": "4", + "processor_speed": "2.7 GHz", + "core_details": { + "total_numberof_cores": "4", + "l2_cache(per_core)": "256 KB" + } + }, + { + "total_numberof_cores": "4", + "l2_cache(per_core)": "256 KB" + } + ] + } + } + nested_alter tutorial