<jupyter_start><jupyter_text>Handy Dict> A library with some handy utils to deal with dictionaries that contain arrays This file will become your README and also the index of your documentation.  Install `pip install handy-dict`  How to use  Let's start with a dictionary<jupyter_code>pikachu = {
  "name": "pikachu",
  "moves": [
    {
      "move": {
        "name": "mega-punch",
        "url": "https://pokeapi.co/api/v2/move/5/"
      }
    },
    {
      "move": {
        "name": "pay-day",
        "url": "https://pokeapi.co/api/v2/move/6/"
      }
    },
    {
      "move": {
        "name": "thunder-punch",
        "url": "https://pokeapi.co/api/v2/move/9/"
      }
    }
  ],
  "stats": [
    {
      "base_stat": 90,
      "effort": 2,
      "stat": {
        "name": "speed",
        "url": "https://pokeapi.co/api/v2/stat/6/"
      }
    },
    {
      "base_stat": 50,
      "effort": 0,
      "stat": {
        "name": "special-defense",
        "url": "https://pokeapi.co/api/v2/stat/5/"
      }
    }
  ]
}<jupyter_output><empty_output><jupyter_text>`apply_keyed`<jupyter_code>from handy_dict import apply_keyed<jupyter_output><empty_output><jupyter_text>With *handy-dict* you can apply a function to the keys inside a dictionary, say you want to take `name` out of `stat`,  go from something like this:```json{  "base_stat": 50,  "effort": 0,  "stat": {    "name": "special-defense",    "url": "https://pokeapi.co/api/v2/stat/5/"  }}```to this:```json{  "base_stat": 50,  "name": "special-defense"}```The function `transform_stat` is just a little helper that will transform the `stats` array in our `pikachu` dictionary and return a new array, that will replace the `stats` in a copy of the original dict:<jupyter_code>def transform_stat(stat_array):
    return {
        stat["stat"]["name"]: stat["base_stat"] 
        for stat in stat_array 
    } 
modified_pikachu = apply_keyed(pikachu,["stats"], transform_stat)
modified_pikachu["stats"]<jupyter_output><empty_output><jupyter_text>`return_keyed`<jupyter_code>from handy_dict import return_keyed<jupyter_output><empty_output><jupyter_text>*handy-dict* also makes it easy to return multiple values from a dictionary, iterating through keys and arrays:<jupyter_code>return_keyed(pikachu, ["moves","move","name"])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15537332757876565, 'fraction_numerical': 0.009926629261976695, 'mean_word_length': 3.348968105065666, 'pattern_counts': {'":': 29, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '345128', 'license': 'Apache-2.0', 'n_tokens_mistral': 853, 'n_tokens_neox': 828, 'n_words': 188, 'path': 'index.ipynb', 'repo_name': 'fferegrino/handy-dict', 'size': '2317'}