[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-13 UTC."],[[["\u003cp\u003eThe \u003ccode\u003erename()\u003c/code\u003e method allows you to rename keys within an Earth Engine Dictionary object.\u003c/p\u003e\n"],["\u003cp\u003eIt takes two required arguments: \u003ccode\u003efrom\u003c/code\u003e (a list of keys to rename) and \u003ccode\u003eto\u003c/code\u003e (a list of new names corresponding to the \u003ccode\u003efrom\u003c/code\u003e list).\u003c/p\u003e\n"],["\u003cp\u003eThe optional \u003ccode\u003eoverwrite\u003c/code\u003e argument, set to \u003ccode\u003efalse\u003c/code\u003e by default, controls whether existing keys can be overwritten during renaming.\u003c/p\u003e\n"]]],["The content describes how to rename keys within a dictionary using the `Dictionary.rename()` method. This method takes two lists: `from` (keys to be renamed) and `to` (new key names), which must have the same length. The optional `overwrite` parameter (default: `false`) allows replacing existing keys. The function returns the modified dictionary. Examples in JavaScript and Python showcase renaming specific keys and overwriting existing ones.\n"],null,["# ee.Dictionary.rename\n\nRename elements in a dictionary.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------------|------------|\n| Dictionary.rename`(from, to, `*overwrite*`)` | Dictionary |\n\n| Argument | Type | Details |\n|--------------------|-------------------------|--------------------------------------------------------------------------------------------------------------------|\n| this: `dictionary` | Dictionary | |\n| `from` | List | A list of keys to be renamed. |\n| `to` | List | A list of the new names for the keys listed in the 'from' parameter. Must have the same length as the 'from' list. |\n| `overwrite` | Boolean, default: false | Allow overwriting existing properties with the same name. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\nvar dict = ee.Dictionary({\n B1: 182,\n B2: 219,\n B3: 443\n});\n\n// Define from-to key name lists for selected keys.\nvar from = ['B2', 'B3'];\nvar to = ['Band_2', 'Band_3'];\nprint('Renamed keys', dict.rename(from, to));\n\nprint('Overwrite existing key names, e.g. B3 becomes B1',\n dict.rename({from: ['B3'], to: ['B1'], overwrite: true}));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\ndic = ee.Dictionary({\n 'B1': 182,\n 'B2': 219,\n 'B3': 443\n})\n\n# Define from-to key name lists for selected keys.\nfrm = ['B2', 'B3']\nto = ['Band_2', 'Band_3']\nprint('Renamed keys:', dic.rename(frm, to).getInfo())\n\ndic_overwrite = dic.rename(**{'from': ['B3'], 'to': ['B1'], 'overwrite': True})\nprint('Overwrite existing key names, e.g. B3 becomes B1:',\n dic_overwrite.getInfo())\n```"]]