# Variables repeating when adding metadata

**URL:** <https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180>\
**Category:** Support & Discussions\
**Tags:** eeg, epochs\
**Created:** [August 7, 2024, 8:42pm UTC](https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180 "2024-08-07T20:42:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![the\_plague.doctor](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@the\_plague.doctor](https://mne.discourse.group/u/the_plague.doctor)\
**Post date:** [August 7, 2024, 8:42pm UTC](https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180/1 "2024-08-07T20:42:01Z")

</div>

- MNE version: e.g. 1.8.0.dev141+g6da505591
- operating system: Windows 10

Hello,

When adding metadata to an epochs object, I am encountering something rather odd. Say I have the following pandas dataframe:

| Stim |
| --- |
| face |
| object |
| face |

I append this dataframe to the epochs object like so:

```python

new_metadata = pd.DataFrame(
    data=(behavdata)*len(myeegdata), columns=["stim"], index=range(len(myeegdata))
)
myeegdata.metadata = new_metadata
myeegdata.metadata.head()

```

It attaches as metadata, but with one weird caveat. When I examine the metadata, the output looks like this:

```python
1 facefacefacefacefacefacefacefacefacefacefacefa...
2 objectobjectobjectobjectobjectobjectobjectobject...
3 facefacefacefacefacefacefacefacefacefacefacefa...

```

Is there a way I can get the variables to stop repeating this way? Thank you very much!

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [August 7, 2024, 9:11pm UTC](https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180/2 "2024-08-07T21:11:24Z")

</div>

Hello @the_plague.doctor and welcome to the forum!

Have you checked what `new_metadata` looks like before attaching it to the epochs?

Richard

---

<div class="post-metadata">

**Author:** ![the\_plague.doctor](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@the\_plague.doctor](https://mne.discourse.group/u/the_plague.doctor)\
**Post date:** [August 7, 2024, 9:13pm UTC](https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180/3 "2024-08-07T21:13:57Z")

</div>

Answering my own question here. I had to edit my code in the following way to get it to work:

```python
new_metadata = pd.DataFrame(
    data=(behavdata), columns=["stim"], index=range(len(myeegdata))
)
myeegdata.metadata = new_metadata
myeegdata.metadata.head()

```

---

<div class="post-metadata">

**Author:** ![the\_plague.doctor](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@the\_plague.doctor](https://mne.discourse.group/u/the_plague.doctor)\
**Post date:** [August 7, 2024, 9:15pm UTC](https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180/4 "2024-08-07T21:15:12Z")

</div>

Hi!

Yes, I attempted to, but got a message saying the dataframe was too large to open. I suspect because of the repeating variables. However, I figured out what the problem was. Thank you so much!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 14, 2024, 9:16pm UTC](https://mne.discourse.group/t/variables-repeating-when-adding-metadata/9180/5 "2024-08-14T21:16:02Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
