# ee.Dictionary.toArray

Returns numeric values of a dictionary as an array. If no keys are specified, all values are returned in the natural ordering of the dictionary's keys. The default 'axis' is 0.

<br />

| Usage | Returns |
|---|---|
| `Dictionary.toArray(*keys*, *axis*)` | Array |

| Argument | Type | Details |
|---|---|---|
| this: `dictionary` | Dictionary |   |
| `keys` | List, default: null |   |
| `axis` | Integer, default: 0 |   |

## Examples

### Code Editor (JavaScript)

```javascript
// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
  B1: 182,
  B2: 219,
  B3: 443
});

print('Values for selected keys converted to ee.Array',
      dict.toArray(['B1', 'B2']));
print('Values for all keys converted to ee.Array',
      dict.toArray());
```
Python setup

See the [Python Environment](https://developers.google.com/earth-engine/guides/python_install) page for information on the Python API and using
`geemap` for interactive development.

```python
import ee
import geemap.core as geemap
```

### Colab (Python)

```python
# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
    'B1': 182,
    'B2': 219,
    'B3': 443
})

display('Values for selected keys converted to ee.Array:',
        dic.toArray(['B1', 'B2']))
display('Values for all keys converted to ee.Array:',
        dic.toArray())
```