# Flatten List of features

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflatten-list-of-features%2F15691%3E%5C
**Category:** 🤗Datasets\
**Created:** [March 14, 2022, 1:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflatten-list-of-features%2F15691 "2022-03-14T13:33:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSamDav](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ssamdav/32/29888_2.png) [@SSamDav](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSSamDav)%5C
**Post date:** [March 14, 2022, 1:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflatten-list-of-features%2F15691%2F1 "2022-03-14T13:33:24Z")

</div>

Hi,

I’m trying to flatten a list of features, however, I don’t know how I can do that 😓  
So I have a dataset like this:

```auto
[
    {"data": [
         {"a": 1},
         {"a": 2}  
    ]},
    {"data": [
         {"a": 3},
         {"a": 4}  
    ]},
]

```

and what to transform into a dataset like this:

```auto
[
    {"data.a": 1},
    {"data.a": 2},
    {"data.a": 3},
    {"data.a": 4},
]

```

How can I achieve this?

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmariosasko)%5C
**Post date:** [April 7, 2022, 12:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflatten-list-of-features%2F15691%2F2 "2022-04-07T12:33:49Z")

</div>

Hi! You can use `Dataset.map` for that:

```python
def flatten_list_of_dict(batch):
    return {"data.a": [dic["a"] for ex_list_of_dict in batch["data"] for dic in ex_list_of_dict]}

ds = ds.map(flatten_list_of_dict, batched=True, remove_columns=["data"])
```
